UNPKG

196 kBJavaScriptView Raw
1module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=30)}([function(t,e){t.exports=require("react")},function(t,e){t.exports=require("@babel/runtime/helpers/getPrototypeOf")},function(t,e){t.exports=require("@babel/runtime/helpers/defineProperty")},function(t,e){t.exports=require("@babel/runtime/helpers/classCallCheck")},function(t,e){t.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},function(t,e){t.exports=require("@babel/runtime/helpers/inherits")},function(t,e){t.exports=require("@babel/runtime/helpers/createClass")},function(t,e){t.exports=require("prop-types")},function(t,e){t.exports=require("@babel/runtime/helpers/get")},function(t,e){t.exports=require("we-edit")},function(t,e){t.exports=require("@babel/runtime/helpers/assertThisInitialized")},function(t,e){t.exports=require("@babel/runtime/helpers/extends")},function(t,e){t.exports=require("@babel/runtime/helpers/objectWithoutProperties")},function(t,e){t.exports=require("memoize-one")},function(t,e){t.exports=require("@babel/runtime/helpers/slicedToArray")},function(t,e){t.exports=require("recompose")},function(t,e){t.exports=require("fontkit")},function(t,e){t.exports=require("is-node")},function(t,e){t.exports=require("react-waypoint")},function(t,e){t.exports=require("linebreak")},function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("@babel/runtime/helpers/construct")},function(t,e){t.exports=require("svgpath")},function(t,e){t.exports=require("simplify-path")},function(t,e){t.exports=require("svg-path-contours")},function(t,e){t.exports=require("@babel/runtime/helpers/objectDestructuringEmpty")},function(t,e){t.exports=require("react-dom")},function(t,e){t.exports=require("@babel/runtime/helpers/typeof")},function(t,e){t.exports=require("htmlparser2")},function(t,e){t.exports=require("get-system-fonts")},function(t,e,n){"use strict";n.r(e);var r={};n.r(r),n.d(r,"enablify",(function(){return ut})),n.d(r,"HasChild",(function(){return L})),n.d(r,"HasParentAndChild",(function(){return F})),n.d(r,"NoChild",(function(){return W})),n.d(r,"Recomposable",(function(){return z})),n.d(r,"Locatable",(function(){return H})),n.d(r,"Stoppable",(function(){return G})),n.d(r,"Continuable",(function(){return X})),n.d(r,"Cacheable",(function(){return V})),n.d(r,"Fissionable",(function(){return at})),n.d(r,"default",(function(){return pt}));var i={};n.r(i),n.d(i,"Document",(function(){return Ot})),n.d(i,"Group",(function(){return yt})),n.d(i,"Text",(function(){return kt})),n.d(i,"Image",(function(){return Ct})),n.d(i,"Shape",(function(){return Pt}));var o={};n.r(o),n.d(o,"SVGMeasure",(function(){return Fr})),n.d(o,"FontMeasure",(function(){return zr}));var s=n(12),a=n.n(s),c=n(10),u=n.n(c),p=n(2),h=n.n(p),l=n(3),d=n.n(l),f=n(6),y=n.n(f),m=n(4),g=n.n(m),v=n(1),b=n.n(v),w=n(8),x=n.n(w),O=n(5),k=n.n(O),C=n(0),P=n.n(C),j=n(7),E=n.n(j),S=n(17),A=n.n(S),M=n(9);function D(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function I(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?D(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var T=function(t){return t.host.onAllChildrenComposed(),null},L=function(t){var e,n;return n=e=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).computed={composed:[],allComposed:void 0},t.debug&&(t.state={computed:t.computed}),t}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){return I({},x()(b()(e.prototype),"getChildContext",this)?x()(b()(e.prototype),"getChildContext",this).call(this):{},{parent:this})}},{key:"render",value:function(){return P.a.createElement(C.Fragment,null,this.children(),P.a.createElement(T,{host:this}))}},{key:"children",value:function(){return P.a.Children.toArray(this.props.children)}},{key:"appendComposed",value:function(t){}},{key:"nextAvailableSpace",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]}},{key:"isAllChildrenComposed",value:function(){return this.computed.allComposed}},{key:"onAllChildrenComposed",value:function(){!1!==this.computed.allComposed&&(this.computed.allComposed=!0)}},{key:"createComposed2Parent",value:function(t){return t}},{key:"dispatch",value:function(){var t;(t=this.context.activeDocStore).dispatch.apply(t,arguments)}},{key:"query",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#".concat(this.props.id);return new M.ContentQuery(this.context.activeDocStore.getState(),t)}},{key:"closest",value:function(t){var e=t;"string"==typeof t&&(e=function(e){return e.getComposeType()==t});for(var n=this;n;){if(e(n))return n;n.context&&(n=n.context.parent)}}},{key:"debug",get:function(){return!!this.context.debug||this.props.debug}}]),e}(t),h()(e,"displayName","composable-".concat(t.displayName)),h()(e,"contextTypes",I({},t.contextTypes,{activeDocStore:E.a.object,debug:E.a.bool})),h()(e,"childContextTypes",I({},t.childContextTypes||{},{parent:E.a.object})),n};function R(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var F=function(t){var e,n,r=L(t);return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"nextAvailableSpace",value:function(){var t;return(t=this.context.parent).nextAvailableSpace.apply(t,arguments)}},{key:"appendComposed",value:function(){return this.context.parent.appendComposed(this.createComposed2Parent.apply(this,arguments))}}]),e}(r),h()(e,"contextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?R(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},r.contextTypes,{parent:E.a.object})),n};function N(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var W=function(t){var e,n,r=F(t);return n=e=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).splittable=!1,t}return k()(e,t),y()(e,[{key:"render",value:function(){return this.context.getMyBreakOpportunities(null),this.appendComposed(),this.onAllChildrenComposed(),null}}]),e}(r),h()(e,"contextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?N(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},r.contextTypes,{getMyBreakOpportunities:E.a.func})),n},z=function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"shouldComponentUpdate",value:function(){return this.clearComposed.apply(this,arguments),!0}},{key:"clearComposed",value:function(t,e){this.computed.composed=[],delete this.computed.allComposed}}]),e}(t),h()(e,"displayName","recomposable-".concat(t.displayName)),n};function q(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function B(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?q(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function Y(t){var e,n;return n=e=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).splittable=!0,t.context.mount&&t.props.id&&t.context.mount(u()(t)),t}return k()(e,t),y()(e,[{key:"componentWillUnmount",value:function(){}},{key:"createComposed2Parent",value:function(){var t=x()(b()(e.prototype),"createComposed2Parent",this).apply(this,arguments);return P.a.isValidElement(t)&&this.props.id?P.a.cloneElement(t,{"data-content":this.props.id,"data-type":this.getComposeType()}):t}}]),e}(t),h()(e,"displayName","locatable-".concat(t.displayName)),h()(e,"propTypes",B({},t.propTypes,{id:E.a.oneOfType([E.a.string,E.a.number]).isRequired})),h()(e,"contextTypes",B({},t.contextTypes,{mount:E.a.func,unmount:E.a.func,getComposer:E.a.func})),n}Y.Locatorize=function(t){var e,n;return n=e=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).composers=new Map([[t.props.id,u()(t)]]);return t.mount=function(t){return n.set(t.props.id,t)},t.unmount=function(t){n.get(t.props.id)==t&&n.delete(t.props.id)},t.getComposer=function(t){return n.get(t)},t}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){var t=this.mount,n=this.unmount,r=this.getComposer;return B({},x()(b()(e.prototype),"getChildContext",this).call(this),{mount:t,unmount:n,getComposer:r})}}]),e}(t),h()(e,"displayName","locator-".concat(t.displayName)),h()(e,"childContextTypes",B({},t.childContextTypes,{mount:E.a.func,unmount:E.a.func,getComposer:E.a.func})),n};var H=Y;function _(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var G=function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return this.context.shouldContinueCompose(this)?x()(b()(e.prototype),"render",this).call(this):null}}]),e}(t),h()(e,"displayName","stoppable-".concat(t.displayName)),h()(e,"contextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?_(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},t.contextTypes,{shouldContinueCompose:E.a.func})),n};function Q(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function U(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Q(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var X=function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){return U({},x()(b()(e.prototype),"getChildContext",this).call(this),{shouldContinueCompose:this.shouldContinueCompose.bind(this)})}},{key:"shouldContinueCompose",value:function(t){throw new Error("shouldContinueCompose must be implemented, and notifyNotAllComposed when false")}},{key:"notifyNotAllComposed",value:function(t){for(t.computed.allComposed=!1;t.context.parent;)t.context.parent.computed.allComposed=!1,t=t.context.parent}}]),e}(t),h()(e,"displayName","continuable-".concat(t.displayName)),h()(e,"childContextTypes",U({},t.childContextTypes,{shouldContinueCompose:E.a.func})),n},V=function(t,e){var n,r;return r=n=function(t){function n(){var t;return d()(this,n),(t=g()(this,b()(n).apply(this,arguments))).computed.lastComposed=[],t.computed.hash=null,t}return k()(n,t),y()(n,[{key:"createComposed2Parent",value:function(){var t=x()(b()(n.prototype),"createComposed2Parent",this).apply(this,arguments);return this.computed.lastComposed.push(t),t}},{key:"clearComposed",value:function(t){t.id;var r=t.hash,i=t.changed,o=void 0===i?r!==this.props.hash:i,s=t.children;if(o||!this.isAllChildrenComposed())if(x()(b()(n.prototype),"clearComposed",this).apply(this,arguments),this.computed.hash=null,e){if(o){var a=C.Children.toArray(s),c=C.Children.toArray(this.props.children),u=c.findIndex((function(t,e){var n=a[e];return!n||n.props.id!==t.props.id||n.props.hash!==t.props.hash}));this.renderChangedPart=function(){switch(u){case 0:return!1;case-1:return this.renderFrom(c.length);default:return!!this.removeChangedPart(c.slice(u).map((function(t){return t.props.id})))&&this.renderFrom(u)}}}}else this.computed.lastComposed=[]}},{key:"render",value:function(){try{if(this.context.shouldContinueCompose&&!this.context.shouldContinueCompose(this))return null;var t=this.props,r=(t.id,t.hash),i=t.changed,o=void 0===i?r!==this.computed.hash:i;if(!o&&this.isAllChildrenComposed()&&!1!==this.appendLastComposed())return null;if(e)if(o){if(this.renderChangedPart){var s=this.renderChangedPart();if(!1!==s)return s}}else if(this.computed.lastComposed.length>0){var a=this.keepUntilLastAllChildrenComposed();if(-1!=a)return this.renderFrom(a+1)}return x()(b()(n.prototype),"clearComposed",this).call(this,this.props),this.computed.hash=null,this.computed.lastComposed=[],x()(b()(n.prototype),"render",this).call(this)}finally{this.computed.hash=this.props.hash}}},{key:"renderFrom",value:function(t){var e=this;if(!1===this.appendLastComposed())return x()(b()(n.prototype),"render",this).call(this);var r=this.children;try{return this.children=function(){return C.Children.toArray(e.props.children).slice(t)},x()(b()(n.prototype),"render",this).call(this)}finally{this.children=r}}},{key:"appendLastComposed",value:function(){var t=this;if(x()(b()(n.prototype),"appendLastComposed",this))return x()(b()(n.prototype),"appendLastComposed",this).apply(this,arguments);this.computed.lastComposed.forEach((function(e){return t.context.parent.appendComposed(e)}))}},{key:"removeChangedPart",value:function(t){return!!x()(b()(n.prototype),"removeChangedPart",this)&&x()(b()(n.prototype),"removeChangedPart",this).apply(this,arguments)}},{key:"findLastChildIndexOfLastComposed",value:function(){return x()(b()(n.prototype),"findLastChildIndexOfLastComposed",this)?x()(b()(n.prototype),"findLastChildIndexOfLastComposed",this).apply(this,arguments):-1}},{key:"findContentId",value:function(t){return function(t,e){return function t(n){return void 0!==(e=n.props["data-content"])||-1!=C.Children.toArray(n.props.children).findIndex(t)}(t),e}(t)}}]),n}(t),h()(n,"displayName","cacheable(".concat(e?"part":"all",")-").concat(t.displayName)),r};function K(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function J(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?K(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function Z(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"navigatable",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i,o;return this.props[t]?(i=this.props)[t].apply(i,n):this.context.parent&&this.context.parent[t]?(o=this.context.parent)[t].apply(o,n):void 0}},{key:"getPages",value:function(){return this.navigatable.apply(this,["getPages"].concat(Array.prototype.slice.call(arguments)))}},{key:"nextLine",value:function(){return this.navigatable.apply(this,["nextLine"].concat(Array.prototype.slice.call(arguments)))}},{key:"prevLine",value:function(){return this.navigatable.apply(this,["prevLine"].concat(Array.prototype.slice.call(arguments)))}},{key:"composeFrames",value:function(){var t;return x()(b()(e.prototype),"composeFrames",this)?x()(b()(e.prototype),"composeFrames",this).apply(this,arguments):this.context&&this.context.parent?(t=this.context.parent).composeFrames.apply(t,arguments):[]}},{key:"position",value:function(t,e){var n,r,i=this.getPages()["find".concat(0==e?"":"Last")]((function(i){var o=0==e?"First":"Last",s=new M.ReactQuery(i.render())["find".concat(o,"AndParents")]('[data-content="'.concat(t,'"]'));return!!(n=(s.first||s.last).get(0))&&(r=s.parents,!0)}));if(n){var o=n.props,s=o.width,a=void 0===s?0:s,c=o.height,u=void 0===c?0:c,p=J({},this.getBound([].concat(r,[n])),{width:a,height:u,id:t,at:e,page:i.props.I});return 1==e&&(p.x+=a),p}}},{key:"positionFromPoint",value:function(){return{}}},{key:"getFocusShape",value:function(){return this.navigatable.apply(this,["getFocusShape"].concat(Array.prototype.slice.call(arguments)))}},{key:"getBound",value:function(t){return t.reduce((function(t,e){var n=e.props||{},r=n.height,i=n.x,o=void 0===i?0:i,s=n.y,a=void 0===s?0:s,c=n["data-type"];return t.x+=o,"text"!==c&&(t.y+=a),"paragraph"==c&&(t.height=r),t}),{x:0,y:0})}},{key:"rectInLine",value:function(t){var e=new M.ReactQuery(t).findFirstAndParents("[data-content=".concat(this.props.id,"]")),n=e.first,r=e.parents,i=[].concat(r,[n.get(0)]).find((function(t){var e=t.props,n=e["data-content"],r=e.width;return n&&r})).props,o=i.x,s=void 0===o?0:o,a=i.y,c=void 0===a?0:a,u=i.width,p=void 0===u?0:u,h=i.height;return{left:s,top:c,width:p,height:void 0===h?0:h}}}]),e}(t),h()(e,"displayName","navigatable-".concat(t.displayName)),h()(e,"propTypes",J({},t.propTypes,{id:E.a.oneOfType([E.a.string,E.a.number]).isRequired})),h()(e,"contextTypes",J({},t.contextTypes,{getComposer:E.a.func})),n}var $=n(21),tt=n.n($),et=n(14),nt=n.n(et),rt=n(13),it=n.n(rt);function ot(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function st(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ot(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ot(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var at=function(t){var e,n;return n=e=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).computed.named={},t}return k()(e,t),y()(e,null,[{key:"fissureLike",value:function(){throw new Error("Fission should be implemented in static fissureLike()")}}]),y()(e,[{key:"getChildContext",value:function(){var t=this;return Object.assign(x()(b()(e.prototype),"getChildContext",this).call(this),{isAnchored:function(){var e;return(e=t.current).isAnchored.apply(e,arguments)},exclusive:function(){var e;return(e=t.current).exclusive.apply(e,arguments)}})}},{key:"named",value:function(t){return this.computed.named[t]}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(arguments.length>2&&arguments[2],this.props.create.bind(this)(st({},e,{id:this.props.id,i:this.computed.composed.length,named:this.named.bind(this)}),st({},n,{parent:this,getComposer:function(e){return t.context.getComposer(e)}})));return this.computed.composed.push(r),r}},{key:"nextAvailableSpace",value:function(t){var e,n=(e=this.current).nextAvailableSpace.apply(e,arguments);return n||(this.create(void 0,void 0,t),this.nextAvailableSpace.apply(this,arguments))}},{key:"appendComposed",value:function(t){var e=t.props,n=e.named,r=e.height;if(!n){var i,o=(i=this.current).appendComposed.apply(i,arguments);return!1===o?(this.create(void 0,void 0,{height:r}),1):Number.isInteger(o)?o:void 0}this.computed.named[n]=arguments[0]}},{key:"getRangeRects",value:function(t,e,n){var r=this,i=function(t){return r.getComposer&&r.getComposer(t)||r.context.getComposer&&r.context.getComposer(t)},o=this.getPages(),s=i(t.id);if(t=s.position(t.id,t.at),e=i(e.id).position(e.id,e.at),!t||!e)return[];if(t.id==e.id&&t.page==e.page&&!s.splittable){var a=[t,e].sort((function(t,e){return t.at-e.at})),c=nt()(a,2),u=c[0],p=c[1],h=n(o.find((function(t){return t.props.I==u.page}))),l=h.x,d=h.y;return[{left:l+u.x,top:d+u.y,right:l+p.x,bottom:d+p.y}]}t.page=o.find((function(e){return e.props.I==t.page})),e.page=o.find((function(t){return t.props.I==e.page})),t.fissionIndex=this.computed.composed.findIndex((function(e){return-1!=(t.line=e.lineIndexOf(t))})),e.fissionIndex=this.computed.composed.findLastIndex((function(t){return-1!=(e.line=t.lineIndexOf(e))}));var f=function(t){var e=n(t),i=e.x,o=e.y,s=new M.ReactQuery(t.render()).findFirstAndParents('[data-content="'.concat(r.props.id,'"]')),a=s.first,c=s.parents;return[].concat(c,[a.get(0)]).reduce((function(t,e){var n=e.props,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x+=i,t.y+=s,t}),{x:i,y:o})},y=[],m=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,o=f(t),s=o.x,a=o.y,c=r.computed.composed[e];c&&c.lines.slice(n,i).forEach((function(t,e){var r=c.lineRect(n+e),i=r.left,o=r.top,u=r.width,p=r.height;y.push({left:i+s,top:o+a,right:i+u+s,bottom:o+p+a})}))},g=t.page.props.I>e.page.props.I?[e,t]:t.page.props.I==e.page.props.I&&t.line>e.line?[e,t]:[t,e],v=nt()(g,2),b=v[0],w=v[1];return b.page==w.page?m(b.page,b.fissionIndex,b.line,w.line+1):(m(b.page,b.fissionIndex,b.line),b.fissionIndex!=w.fissionIndex&&(o.slice(b.page.props.I+1,w.page.props.I).forEach((function(t,e){return m(t,e+b.fissionIndex+1)})),m(w.page,w.fissionIndex,0,w.line+1))),y.length&&(Object.assign(y[0],{left:n(b.page).x+b.x}),Object.assign(y[y.length-1],{right:n(w.page).x+w.x})),y}},{key:"Fission",get:function(){var t=this;return it()((function(e){return t.constructor.fissureLike(e)}))(this.context.ModelTypes.Frame)}},{key:"current",get:function(){return 0==this.computed.composed.length&&this.create(),this.computed.composed[this.computed.composed.length-1]}}]),e}(t),h()(e,"defaultProps",st({},t.defaultProps,{create:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return tt()(this.Fission,e)}})),h()(e,"contextTypes",st({},t.contextTypes,{ModelTypes:E.a.object})),h()(e,"childContextTypes",st({},t.childContextTypes,{isAnchored:E.a.func,exclusive:E.a.func})),h()(e,"displayName","fissionable-".concat(t.displayName)),n};function ct(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var ut=function(t){return function(e,n){return Object.keys(e).reduce((function(n,r){return n[r]||(n[r]=t(e[r])),n}),function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ct(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ct(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},n))}};function pt(t,e){var n=e.locatable,r=e.navigatable,i=e.stoppable,o=e.continuable,s=e.recomposable,a=e.fissionable;return n&&(t=H(t)),r&&(t=Z(t)),i&&(t=G(t)),o&&(t=X(t)),s&&(t=z(t)),a&&(t=at(t)),t}[L,F,W,z,H,Z,G,X,V,at].forEach((function(t){return t.enable=ut(t)}));var ht=n(11),lt=n.n(ht),dt=n(18),ft=n.n(dt),yt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.innerRef,n=t.rotate,r=t.x,i=void 0===r?0:r,o=t.y,s=void 0===o?0:o,c=t.children,u=t.background,p=(t.margin,t.minWidth,t.width),h=t.height,l=(t.index,t.childIndex,t.geometry,t.contentWidth,t.wrap,t.pagination,t.anchor,t.currentY,t.named,t.descent,t.replaceable,t.spaceHeight,t.composedAt,t.className),d=a()(t,["innerRef","rotate","x","y","children","background","margin","minWidth","width","height","index","childIndex","geometry","contentWidth","wrap","pagination","anchor","currentY","named","descent","replaceable","spaceHeight","composedAt","className"]),f={};e&&(f.ref=e),"page"==l&&(f.className=l);var y="";(i||s)&&(y="translate(".concat(parseInt(i||0)," ").concat(parseInt(s||0),")")),n&&(y="".concat(y," rotate(").concat(n,")")),y.length>0&&(f.transform=y);var m=P.a.createElement(C.Fragment,null,u&&"transparent"!=u&&P.a.createElement("rect",{width:p,height:h,fill:u,key:"background"}),C.Children.toArray(c).map((function(t,e){return P.a.cloneElement(t,{key:e})})));return this.context.debug?P.a.createElement("g",lt()({},d,f),m):Object.keys(f).length?P.a.createElement("g",f,m):m}}]),e}(C.Component);function mt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(yt,"contextTypes",{debug:E.a.bool}),h()(yt,"propTypes",{width:E.a.number,height:E.a.number,x:E.a.number,y:E.a.number});var gt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.pgGap,r=t.width,i=t.precision,o=t.media,s=void 0===o?this.context.media:o,a=t.paper,c=void 0===a?this.context.paper:a,u=t.smart,p=void 0===u||u;switch(s){case"screen":var h=0;return P.a.createElement(yt,{y:n,x:0},e.map((function(t,e){var o=t.props,s=o.width,a=o.height,u=o.margin,l=P.a.createElement(yt,lt()({key:e},{y:h,x:(r-s)/2},{className:"page"}),p?P.a.createElement(vt,{children:t,i:e,width:s,height:a,margin:u,paper:c,precision:i}):t);return h+=a+n,l})));default:return e}}}]),e}(C.Component);h()(gt,"contextTypes",{media:E.a.string,paper:E.a.oneOfType([E.a.bool,E.a.shape({border:E.a.bool})])});var vt=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{display:!1}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state.display,n=this.props,r=n.children,i=(n.i,n.width),o=n.height,s=n.margin,a=n.paper,c=void 0===a||a,u=n.precision;return P.a.createElement(ft.a,{fireOnRapidScroll:!1,onEnter:function(e){t.setState({display:!0})},onLeave:function(e){return t.setState({display:!1})}},P.a.createElement("g",null,c&&P.a.createElement(bt,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?mt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({width:i,height:o,margin:s,fill:"white",precision:u},c)),e?r:null))}}]),e}(C.Component),bt=function(t){var e=t.width,n=t.height,r=t.margin,i=r.left,o=r.right,s=r.top,c=r.bottom,u=t.precision,p=t.border,h=void 0===p||p,l=t.strokeWidth,d=void 0===l?1*u:l,f=t.marginWidth,y=void 0===f?20*u:f,m=a()(t,["width","height","margin","precision","border","strokeWidth","marginWidth"]);return P.a.createElement("g",{className:"paper"},P.a.createElement("rect",lt()({},m,{width:e,height:n})),h&&P.a.createElement("path",{strokeWidth:d,stroke:"lightgray",fill:"none",d:"\n\t\t \t\tM0 0 h".concat(e," v").concat(n," h").concat(-e,"z\n\t\t\t\tM").concat(i-Math.min(i,y)," ").concat(s," h").concat(Math.min(i,y)," v").concat(-Math.min(s,y),"\n\t\t\t\tM").concat(i-Math.min(i,y)," ").concat(n-c," h").concat(Math.min(i,y)," v").concat(Math.min(c,y),"\n\t\t\t\tM").concat(e-o+Math.min(o,y)," ").concat(n-c," h").concat(-Math.min(o,y)," v").concat(Math.min(c,y),"\n\t\t\t\tM").concat(e-o+Math.min(o,y)," ").concat(s," h").concat(-Math.min(o,y)," v").concat(-Math.min(s,y),"\n\t\t\t")}))};function wt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function xt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?wt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Ot=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"getComposed",it()((function(t,e){var n=t.map((function(t,e){return t.render()}));return n.reduce((function(t,n){var r=n.props,i=r.width,o=r.height;return Object.assign(t,{width:Math.max(t.width,i),height:t.height+o+e})}),{width:0,height:e,composed:n})}))),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.pages,n=t.pgGap,r=t.scale,i=t.style,o=t.children,s=t.innerRef,c=(t.content,t.precision),u=void 0===c?1:c,p=a()(t,["pages","pgGap","scale","style","children","innerRef","content","precision"]),h=this.getComposed(e,n),l=h.width,d=h.height,f=h.composed;return P.a.createElement("svg",lt()({},p,{ref:s,preserveAspectRatio:"xMidYMin",viewBox:"0 0 ".concat(l," ").concat(d),style:xt({background:"transparent",width:l*r/u,height:d*r/u},i)}),P.a.createElement(gt,{pgGap:n*u,width:l,precision:u},f),o)}}]),e}(C.Component);h()(Ot,"displayName","composed"),h()(Ot,"propTypes",{pages:E.a.arrayOf(E.a.object).isRequired,pgGap:E.a.number.isRequired,scale:E.a.number.isRequired}),h()(Ot,"defaultProps",{pgGap:24,scale:1}),h()(Ot,"contextTypes",{events:E.a.shape({emit:E.a.func.isRequired})});var kt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=(t.whiteSpace,t.color),r=t.highlight,i=t.border,o=t.underline,s=t.strike,c=t.descent,u=(t.minWidth,t.height),p=t.width,h=(t.composedAt,t.y),l=a()(t,["children","whiteSpace","color","highlight","border","underline","strike","descent","minWidth","height","width","composedAt","y"]),d=null;if(r||i){var f={width:Math.ceil(p),height:Math.ceil(u),fill:r||"none",x:0,y:h-u+c};i&&(f.stroke="black",f.strokeWidth=.5),d=P.a.createElement("rect",f)}var y=null;if(o){var m=Math.ceil(c/2),g=function(t){switch(o){case"double":return 1;default:return.5}}();y=P.a.createElement("line",{y1:m,x2:p,y2:m,stroke:"black",strokeWidth:g})}var v=null;if(s){var b=-c;v=P.a.createElement("line",{y1:b,x2:p,y2:b,stroke:"black",strokeWidth:.5})}return P.a.createElement(C.Fragment,null,d,v,y,P.a.createElement("text",lt()({style:{userSelect:"none",whiteSpace:"pre",cursor:"text"},y:h||0},l,{fill:n}),e))}}]),e}(C.PureComponent),Ct=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return P.a.createElement("image",this.props)}}]),e}(C.PureComponent),Pt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return null}}]),e}(C.Component);function jt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Et(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?jt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var St=M.dom.Document,At=H.Locatorize(L(St)),Mt=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"getMeasure",it()((function(){var t=n.props.precision,e=void 0===t?1:t;return 1==e?n.context.Measure:function(t){function n(){return d()(this,n),g()(this,b()(n).apply(this,arguments))}return k()(n,t),y()(n,[{key:"lineHeight",value:function(){for(var t,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];var s=(t=x()(b()(n.prototype),"lineHeight",this)).call.apply(t,[this].concat(i)),a=s.height,c=s.descent;return{height:a*e,descent:c*e}}},{key:"stringWidth",value:function(){for(var t,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return e*(t=x()(b()(n.prototype),"stringWidth",this)).call.apply(t,[this].concat(i))}}]),n}(n.context.Measure)}))),n}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){return Et({},x()(b()(e.prototype),"getChildContext",this).call(this),{Measure:this.getMeasure()})}},{key:"render",value:function(){var t=this.props.canvas;return P.a.createElement(C.Fragment,null,x()(b()(e.prototype),"render",this).call(this),P.a.cloneElement(t,{content:this.renderComposed()}))}},{key:"renderComposed",value:function(){var t=this.props.precision,e=void 0===t?1:t;return P.a.createElement(Ot,{pages:this.computed.composed,precision:e})}},{key:"appendComposed",value:function(t){-1==this.computed.composed.indexOf(t)&&this.computed.composed.push(t)}},{key:"componentDidMount",value:function(){this.dispatch(M.ACTION.Statistics({pages:this.computed.composed.length}))}}]),e}(At);function Dt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function It(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Dt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(Mt,"contextTypes",Et({},At.contextTypes,{Measure:E.a.func})),h()(Mt,"childContextTypes",Et({},At.childContextTypes,{Measure:E.a.func}));var Tt=at(F(M.dom.Section)),Lt=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"getDocument",it()((function(){for(var t=n.context.parent;t;){if("document"==t.getComposeType())return t;t=t.context.parent}return t}))),n}return k()(e,t),y()(e,[{key:"create",value:function(){var t=x()(b()(e.prototype),"create",this).call(this,{I:this.totals});return this.context.parent.appendComposed(this.createComposed2Parent(t)),t}},{key:"createComposed2Parent",value:function(t){return t}},{key:"totals",get:function(){return this.getDocument().computed.composed.length}}]),e}(Tt);h()(Lt,"fissureLike",(function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"defineProperties",value:function(){x()(b()(e.prototype),"defineProperties",this).call(this),Object.defineProperties(this,{cols:{enumerable:!1,configurable:!0,get:function(){var t=this.props,e=t.width,n=t.height,r=t.margin,i=(r=void 0===r?{}:r).left,o=void 0===i?0:i,s=r.right,a=void 0===s?0:s,c=r.top,u=void 0===c?0:c,p=r.bottom,h=void 0===p?0:p,l=t.cols;return void 0===l?[{x:o,y:u,width:e-o-a,height:n-u-h}]:l}},composedHeight:{enumerable:!1,configurable:!0,get:function(){var t=this.context.parent;return this!=t.current||t.isAllChildrenComposed()?this.props.height:Math.max.apply(Math,this.columns.map((function(t){return t.y+(t.height-t.availableHeight)})))}}})}},{key:"getComposeType",value:function(){return Lt.getType()}},{key:"render",value:function(){var t=this.props,n=t.I,r=t.width,i=t.height,o=t.margin;return P.a.cloneElement(x()(b()(e.prototype),"createComposed2Parent",this).call(this),{key:n,width:r,height:i,margin:o})}},{key:"lineIndexOf",value:function(t){var n=t.page;return n?n==this?x()(b()(e.prototype),"lineIndexOf",this).apply(this,arguments):-1:x()(b()(e.prototype),"lineIndexOf",this).apply(this,arguments)}}]),e}(t),h()(e,"displayName","frame-section"),n})),h()(Lt,"defaultProps",It({},Tt.defaultProps,{create:function(t,e){var n=this.props.page;if(n){var r=n.width,i=n.height,o=n.margin,s=(o=void 0===o?{}:o).left,a=void 0===s?0:s,c=o.right,u=void 0===c?0:c,p=o.top,h=void 0===p?0:p,l=o.bottom,d=void 0===l?0:l,f=(o.header,o.footer,n.cols),y=r-a-u,m=f;if(!Array.isArray(f)){var g=f||{},v=g.num,b=void 0===v?1:v,w=g.space,x=void 0===w?0:w,O=g.y,k=void 0===O?h:O;m=new Array(b).fill({width:(y-(b-1)*x)/b,space:x}).reduce((function(t,e){var n=e.width,r=e.space;return t.columns.push({x:t.x,width:n,y:k}),t.x+=r+n,t}),{x:a,columns:[]}).columns}return new this.Fission(It({width:r,height:i,margin:{left:a,right:u,top:h,bottom:d},cols:m},t),e)}throw new Error("section has no create")}}));var Rt=n(19),Ft=n.n(Rt);function Nt(t){for(var e,n=new Ft.a(t),r=0,i=[];e=n.nextBreak();)i.push(t.slice(r,e.position)),e.required,r=e.position;return i}function Wt(t,e){this.set(t,e)}function zt(t,e,n,r){this.left=t,this.top=e,this.right=t+n,this.bottom=e+r}function qt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Bt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?qt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}Wt.prototype={clone:function(){return new Wt(this.x,this.y)},set:function(t,e){return this.x=t,this.y=e,this},equals:function(t,e){return this.x==t&&this.y==e},toString:function(){return"("+this.x+","+this.y+")"},map:function(t){return this.x=t.call(this,this.x),this.y=t.call(this,this.y),this},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},scale:function(t){return this.x*=t,this.y*=t,this},isZero:function(){return 0==this.x&&0==this.y}},function(){function t(t){return function(e,n){return void 0===n?t.call(this,e.x,e.y):t.call(this,e,n)}}for(var e=0,n=["add","subtract","equals","set"];e<n.length;e++){var r=n[e];Wt.prototype[r]=t(Wt.prototype[r])}}(),zt.fromRect=function(t){return new zt(t.left,t.top,t.right-t.left,t.bottom-t.top)},zt.prototype={get x(){return this.left},get y(){return this.top},get width(){return this.right-this.left},get height(){return this.bottom-this.top},set x(t){var e=this.left-t;this.left=t,this.right-=e},set y(t){var e=this.top-t;this.top=t,this.bottom-=e},set width(t){this.right=this.left+t},set height(t){this.bottom=this.top+t},isEmpty:function(){return this.left>=this.right||this.top>=this.bottom},setRect:function(t,e,n,r){return this.left=t,this.top=e,this.right=t+n,this.bottom=e+r,this},setBounds:function(t,e,n,r){return this.top=e,this.left=t,this.bottom=r,this.right=n,this},equals:function(t){return null!=t&&(this.isEmpty()&&t.isEmpty()||this.top==t.top&&this.left==t.left&&this.bottom==t.bottom&&this.right==t.right)},clone:function(){return new zt(this.left,this.top,this.right-this.left,this.bottom-this.top)},center:function(){if(this.isEmpty())throw"Empty rectangles do not have centers";return new Wt(this.left+(this.right-this.left)/2,this.top+(this.bottom-this.top)/2)},copyFrom:function(t){return this.top=t.top,this.left=t.left,this.bottom=t.bottom,this.right=t.right,this},translate:function(t,e){return this.left+=t,this.right+=t,this.top+=e,this.bottom+=e,this},toString:function(){return"["+this.x+","+this.y+","+this.width+","+this.height+"]"},union:function(t){return this.clone().expandToContain(t)},contains:function(t){return!!t.isEmpty()||!this.isEmpty()&&(t.left>=this.left&&t.right<=this.right&&t.top>=this.top&&t.bottom<=this.bottom)},intersect:function(t){return this.clone().restrictTo(t)},intersects:function(t){if(this.isEmpty()||t.isEmpty())return!1;var e=Math.max(this.left,t.left),n=Math.min(this.right,t.right),r=Math.max(this.top,t.top),i=Math.min(this.bottom,t.bottom);return e<n&&r<i},restrictTo:function(t){if(this.isEmpty()||t.isEmpty())return this.setRect(0,0,0,0);var e=Math.max(this.left,t.left),n=Math.min(this.right,t.right),r=Math.max(this.top,t.top),i=Math.min(this.bottom,t.bottom);return this.setRect(e,r,Math.max(0,n-e),Math.max(0,i-r))},expandToContain:function(t){if(this.isEmpty())return this.copyFrom(t);if(t.isEmpty())return this;var e=Math.min(this.left,t.left),n=Math.max(this.right,t.right),r=Math.min(this.top,t.top),i=Math.max(this.bottom,t.bottom);return this.setRect(e,r,n-e,i-r)},expandToIntegers:function(){return this.left=Math.floor(this.left),this.top=Math.floor(this.top),this.right=Math.ceil(this.right),this.bottom=Math.ceil(this.bottom),this},scale:function(t,e){return this.left*=t,this.right*=t,this.top*=e,this.bottom*=e,this},map:function(t){return this.left=t.call(this,this.left),this.top=t.call(this,this.top),this.right=t.call(this,this.right),this.bottom=t.call(this,this.bottom),this},translateInside:function(t){var e=0;this.left<=t.left?e=t.left-this.left:this.right>t.right&&(e=t.right-this.right);var n=0;return this.top<=t.top?n=t.top-this.top:this.bottom>t.bottom&&(n=t.bottom-this.bottom),this.translate(e,n)},subtract:function(t){var e=new zt(0,0,0,0),n=[];return(t=t.intersect(this)).isEmpty()?[this.clone()]:(e.setBounds(this.left,this.top,t.left,this.bottom),e.isEmpty()||n.push(e.clone()),e.setBounds(t.left,this.top,t.right,t.top),e.isEmpty()||n.push(e.clone()),e.setBounds(t.left,t.bottom,t.right,this.bottom),e.isEmpty()||n.push(e.clone()),e.setBounds(t.right,this.top,this.right,this.bottom),e.isEmpty()||n.push(e.clone()),n)},blend:function(t,e){return new zt(this.left+(t.left-this.left)*e,this.top+(t.top-this.top)*e,this.width+(t.width-this.width)*e,this.height+(t.height-this.height)*e)},inflate:function(t,e){var n=(this.width*t-this.width)/2,r=arguments.length>1?e:t,i=(this.height*r-this.height)/2;return this.left-=n,this.right+=n,this.top-=i,this.bottom+=i,this},inflateFixed:function(t){return this.left-=t,this.right+=t,this.top-=t,this.bottom+=t,this}};var Yt=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).defineProperties(),t}return k()(e,t),y()(e,[{key:"defineProperties",value:function(){Object.defineProperties(this,{firstLine:{enumerable:!0,configurable:!0,get:function(){return this.lines[0]}},lastLine:{enumerable:!0,configurable:!0,get:function(){var t=this.lines;return t[t.length-1]}},lines:{enumerable:!0,configurable:!0,get:function(){return this.computed.composed.filter((function(t){return null==t.props.y}))},set:function(t){if(t&&0!=t.length)throw new Error("not support");return this.computed.composed=this.anchors}},totalLines:{enumerable:!0,configurable:!0,get:function(){return this.lines.length}},dividing:{enumerable:!0,configurable:!0,get:function(){var t,e,n,r,i,o=this;return t=this.props,e=t.x,n=void 0===e?0:e,r=t.y,i=void 0===r?0:r,{x1:n,x2:n+t.width,y2:i+o.currentY}}},currentY:{enumerable:!1,configurable:!0,get:function(){this.props.height;return this.computed.composed.reduce((function(t,e){var n=e.props,r=n.height,i=n.y;return(void 0===i?t:i)+r}),0)}},anchors:{enumerable:!0,configurable:!0,get:function(){return this.computed.composed.filter((function(t){return void 0!==t.props.y}))}},wrappees:{enumerable:!0,configurable:!0,get:function(){return this.anchors.filter((function(t){return!!t.props.wrap}))}},contentHeight:{enumerable:!0,configurable:!0,get:function(){return this.currentY}}})}},{key:"appendComposed",value:function(t){this.computed.composed.push(t)}},{key:"onAllChildrenComposed",value:function(){this.context.parent.appendComposed(this.createComposed2Parent()),x()(b()(e.prototype),"onAllChildrenComposed",this).call(this)}},{key:"createComposed2Parent",value:function(){var t=this.props,e=t.width,n=t.height,r=void 0===n?this.contentHeight:n,i=t.x,o=t.y,s=t.z,a=t.named;return P.a.createElement(yt,{width:e,height:r,x:i,y:o,z:s,named:a,className:"frame"},this.positionLines(this.computed.composed))}},{key:"positionLines",value:function(t){return t.reduce((function(t,e,n){return null==e.props.y?(t.positioned.push(P.a.cloneElement(e,{y:t.y,key:n})),t.y+=e.props.height):t.positioned.push(P.a.cloneElement(e,{key:n})),t}),{y:0,positioned:[]}).positioned}},{key:"belongsTo",value:function(t,e){return new M.ReactQuery(t).findFirst('[data-content="'.concat(e,'"]')).get(0)}},{key:"isAnchored",value:function(t){var e=this;return!!this.anchors.find((function(n){return e.belongsTo(n,t)}))}},{key:"isIntersect",value:function(t,e){return new zt(t.x,t.y,t.width,t.height).intersects(new zt(e.x,e.y,e.width,e.height))}},{key:"isDirtyIn",value:function(t){var e=this;return!!this.wrappees.find((function(n){var r=n.props,i=r.x,o=r.y,s=r.width,a=r.height;return e.isIntersect(t,{x:i,y:o,width:s,height:a})}))||this.isIntersect(t,{x:0,y:0,width:width,height:this.currentY})}},{key:"paragraphY",value:function(t){var e=this,n=this.lines.findLast((function(n){return e.getParagraph(n)!=t}));return n?this.lineY(n):0}},{key:"lineY",value:function(t){return this.lines.slice(0,this.lines.indexOf(t)+1).reduce((function(t,e){var n=e.props.height;return t+(void 0===n?0:n)}),0)}},{key:"getFlowableComposerId",value:function(t,e){return new M.ReactQuery(t).findFirst('[data-type="paragraph"],[data-type="table"]').filter(e).attr("data-content")}},{key:"getParagraph",value:function(t){return new M.ReactQuery(t).findFirst('[data-type="paragraph"]').attr("data-content")}},{key:"isEmpty",value:function(){return 0==this.totalLines}},{key:"reset4Recompose",value:function(){var t=this.lines;return this.lines=[],t}},{key:"exclusive",value:function(t,e){var n=this.dividing;return null!=e&&(n.y2=e),null!=t&&(n.y1=t),this.wrappees.reduce((function(t,e){var r=(0,e.props.wrap)(n);return t.splice.apply(t,[t.length,0].concat(Array.isArray(r)?r:[r])),t}),[]).filter((function(t){return!!t})).filter((function(t){return t.width>0})).map((function(t){return t.x-=n.x1,t}))}},{key:"recompose",value:function(){for(var t,e=this.reset4Recompose(),n=null,r=[],i=0;i<e.length;i++){t=e[i];var o=this.getFlowableComposerId(t,'[data-type="paragraph"]');if(o){if(n){if(o!==n){this.context.getComposer(n).recommit(r),n=o,r=[t];continue}r.push(t);continue}n=o,r.push(t)}else n&&(this.context.getComposer(n).recommit(r),n=null,r=[]),this.appendComposed(t)}n&&this.context.getComposer(n).recommit(r)}},{key:"layoutOf",value:function(){var t=this.props;return{width:t.width,height:t.height}}},{key:"lineIndexOf",value:function(t){var e=this.lines,n=t.lineIndexOfParagraph,r=t.paragraph,i=t.id,o=t.at;return r?e.findIndex((function(t){return new M.ReactQuery(t).findFirst((function(t){var e=t.props,i=e["data-content"],o=e["data-type"],s=e.pagination,a=(s=void 0===s?{}:s).i;return i==r&&a==n+1||"paragraph"!=o&&void 0})).length})):e["find".concat(0==o?"":"Last","Index")]((function(t){return new M.ReactQuery(t)[0==o?"findFirst":"findLast"]('[data-content="'.concat(i,'"]')).length}))}},{key:"clone",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.computed;return Object.assign(new this.constructor(Bt({},this.props,{},t),this.context),{computed:e})}}]),e}(F(M.dom.Frame));function Ht(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(Yt,"IMMEDIATE_STOP",Number.MAX_SAFE_INTEGER);var _t=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"defineProperties",value:function(){x()(b()(e.prototype),"defineProperties",this).call(this),this.computed.columns=[],Object.defineProperties(this,{lines:{enumerable:!0,configurable:!0,get:function(){return this.columns.reduce((function(t,e){return[].concat(t,e.children)}),[])}},dividing:{enumerable:!0,configurable:!0,get:function(){var t=this;return function(e){var n=e.width,r=e.x,i=void 0===r?0:r;e.y;return{x1:i,x2:i+n,y2:t.currentY}}(this.currentColumn)}},currentY:{enumerable:!1,configurable:!0,get:function(){return(this.currentColumn.y||0)+this.currentColumn.currentY}},contentHeight:{enumerable:!1,configurable:!0,get:function(){return Math.max.apply(Math,this.columns.map((function(t){return t.height||t.currentY})))}},anchors:{enumerable:!0,configurable:!0,get:function(){return this.computed.composed}},currentColumn:{enumerable:!0,configurable:!0,get:function(){return 0==this.columns.length&&this.createColumn(),this.columns[this.columns.length-1]}},cols:{enumerable:!1,configurable:!0,get:function(){var t=this.props,e=t.width,n=t.cols;return void 0===n?[{x:0,y:0,width:e}]:n}},columns:{enumerable:!0,configurable:!0,get:function(){return this.computed.columns},set:function(t){return this.computed.columns=[]}}})}},{key:"createColumn",value:function(){var t=Object.defineProperties(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ht(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ht(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({height:this.props.height},this.cols[this.columns.length],{children:[],className:"column"}),{availableHeight:{enumerable:!1,configurable:!1,get:function(){return null==this.height?Number.MAX_SAFE_INTEGER:this.height-this.currentY}},currentY:{enumerable:!0,configurable:!1,get:function(){return this.children.reduce((function(t,e){var n=e.props,r=n.height;n.y;return t+r}),0)}}});return this.columns.push(t),t}},{key:"isEmpty",value:function(){return 0==this.totalLines&&0==this.anchors.length}},{key:"lineY",value:function(t){var e=this.columns.find((function(e){return e.children.includes(t)}))||this.currentColumn,n=e.y,r=void 0===n?0:n,i=e.children;return i.slice(0,i.indexOf(t)+1).reduce((function(t,e){var n=e.props,r=n.height,i=n.y;return(void 0===i?t:i)+r}),r)}},{key:"createComposed2Parent",value:function(){var t=this,n=function(e){var n=t.props,r=n.height,i=void 0===r?e:r;switch(n.vertAlign){case"bottom":return i-e;case"center":case"middle":return(i-e)/2;default:return 0}},r=x()(b()(e.prototype),"createComposed2Parent",this).call(this,[]);return P.a.cloneElement(r,{children:[].concat(this.anchors,this.columns.map((function(e,r){var i=e.children,o=(e.currentY,e["data-content"],e["data-type"],e.id,a()(e,["children","currentY","data-content","data-type","id"]));return P.a.createElement(yt,lt()({},o,{key:r}),P.a.createElement(yt,{y:n(e.currentY)},t.positionLines(i)))})))})}},{key:"nextAvailableSpace",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(t.width,t.height),n=void 0===e?0:e,r=t.y,i=void 0===r?this.currentY:r;return i+n-(this.currentColumn.height+(this.currentColumn.y||0))>1&&this.currentColumn.children.length>0?this.cols.length>this.columns.length&&(this.createColumn(),this.nextAvailableSpace(t)):{maxWidth:this.currentColumn.width,width:this.currentColumn.width,height:this.currentColumn.availableHeight,frame:this,wrappees:this.exclusive(i,i+n),y:i}}},{key:"appendComposed",value:function(t){var e=t.props,n=e.height,r=e.x,i=e.y;e.width;if(null==r||null==i)return n-this.currentColumn.availableHeight>1&&this.currentColumn.children.length>0?this.cols.length>this.columns.length&&(this.createColumn(),1):this.appendLine(t);this.computed.composed.push(t)}},{key:"appendLine",value:function(t){this.currentColumn.children.push(t)}},{key:"reset4Recompose",value:function(){var t=x()(b()(e.prototype),"reset4Recompose",this).apply(this,arguments);return this.columns=[],t}},{key:"isDirtyIn",value:function(t){var e=this;return!!this.wrappees.find((function(n){var r=n.props,i=r.x,o=r.y,s=r.width,a=r.height;return e.isIntersect(t,{x:i,y:o,width:s,height:a})}))||!!this.columns.find((function(n){var r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o,a=n.width,c=n.currentY;return e.isIntersect(t,{x:i,y:s,width:a,height:c})}))}},{key:"columnIndexOf",value:function(t){return this.columns.reduce((function(t,e,n){return t.count>0&&(t.count-=e.children.length,t.i=n),t}),{count:t+1,i:0}).i}},{key:"layoutOf",value:function(){return Object.assign(x()(b()(e.prototype),"layoutOf",this).call(this),{cols:this.cols})}},{key:"includeContent",value:function(t){var e=this;return!!this.columns.find((function(e){return e.id==t}))||!![].concat(this.lines,this.anchors).find((function(n){return e.belongsTo(n,t)}))}},{key:"rollbackLines",value:function(t){var e=this,n=[];if(0==t)return n.anchors=[],n;for(var r=this.columns.length-1;r>-1;r--){var i=this.columns[r].children;if(t<=i.length){n=n.concat(i.splice(-t));break}n=n.concat(this.columns.splice(r)[0].children),t-=i.length}var o=function(t){var n=function(t){return new M.ReactQuery(t).findFirst('[data-type="anchor"]').attr("data-content")},r=Array.from(t.reduce((function(t,e){return t.add(n(e)),t}),new Set)).filter((function(t){return!!t}));return e.computed.composed.filter((function(t){return r.includes(n(t))})).map((function(t){return e.computed.composed.splice(e.computed.composed.indexOf(t),1),t}))}(n);return n.anchors=o,n}}]),e}(Yt);h()(_t,"Columnable",_t);var Gt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"onAllChildrenComposed",value:function(){null==this.props.height&&this.props.balance&&this.balance(),x()(b()(e.prototype),"onAllChildrenComposed",this).apply(this,arguments)}},{key:"balance",value:function(){var t=this.cols[0].width,e=this.lines;this.cols.find((function(e){return t!==e.width}))?this.anyBalance(e,this.cols):(this.columns=[],this.equalBalance(e,this.cols))}},{key:"equalBalance",value:function(t,e){var n=this,r=t.reduce((function(t,e){var n=e.height,r=e.y;return(void 0===r?t:r)+n}),0)/e.length-10;t.reduce((function(t,e){return t.h<r?(t.cols[t.cols.length-1].push(e),t.h+=e.props.height):(t.cols.push([e]),t.h=e.props.height),t}),{cols:[[]],h:0}).cols.forEach((function(t){return Object.assign(n.createColumn(),{children:t})}))}},{key:"anyBalance",value:function(t,e){var n=this,r=this.createColumn,i=this.reset4Recompose;try{var o=e.reduce((function(t,e){return t+e.width}),0);this.createColumn=function(){return Object.assign(r.call(n),{width:o,height:Number.MAX_SAFE_INTEGER})},this.recompose();var s=this.currentColumn.currentY;this.createColumn=function(){return Object.assign(r.call(n),{height:s})},this.recompose()}finally{this.createColumn=r,this.reset4Recompose=i}}}]),e}(_t);h()(Gt,"Balanceable",Gt);var Qt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"defineProperties",value:function(){x()(b()(e.prototype),"defineProperties",this).call(this),Object.defineProperties(this,{prev:{enumerable:!1,configurable:!0,get:function(){var t=this.context.parent.computed.composed;return t[t.indexOf(this)-1]}}})}},{key:"orphanCount",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.lastLine,n=this.getFlowableComposerId(e,'[data-type="paragraph"]');if(!n)return 0;var r=this.lines,i=r.findLastIndex((function(e){return t.getFlowableComposerId(e)!==n}));return-1==i?r.length:i+1}},{key:"appendLine",value:function(t){if(this.isEmpty()&&this.prev){var n=this.rollback4PaginationControl(t);if(Number.isInteger(n))return n}return x()(b()(e.prototype),"appendLine",this).apply(this,arguments)}},{key:"rollback4PaginationControl",value:function(t){var e=t.props.pagination,n=void 0===e?{}:e,r=n.widow,i=n.orphan,o=n.keepLines,s=n.last;if(o){if(this.prev.shouldKeepLinesWith(t)){var a=this.prev.orphanCount();return this.prev.rollbackLines(a),a+1}}else{if(i&&1==this.prev.orphanCount(t)&&this.prev.lines.length>1)return this.prev.rollbackLines(1),2;if(r&&s){var c=this.prev.orphanCount(t);if(c>0&&this.prev.lines.length>c)return this.prev.rollbackLines(1),i&&2==c?(this.prev.rollbackLines(1),3):2}}if(this.prev.shouldKeepWithNext(t)){var u=this.prev.rollbackLines(this.prev.orphanCount()),p=this.getFlowableComposerId(u[0]);return this.context.getComposer(p).recommit(),1}}},{key:"shouldKeepLinesWith",value:function(t){var e=this.getFlowableComposerId(t);return this.getFlowableComposerId(this.lastLine)==e&&this.getFlowableComposerId(this.firstLine)!=e}},{key:"shouldKeepWithNext",value:function(t){return(this.lastLine.props.pagination||{}).keepWithNext&&0==this.orphanCount(t)&&this.getFlowableComposerId(this.firstLine)!==this.getFlowableComposerId(this.lastLine)}}]),e}(Gt);function Ut(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Xt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ut(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ut(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(Qt,"PaginationControllable",Qt);var Vt=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"nextAvailableSpace",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.width,r=void 0===n?0:n,i=t.height,o=void 0===i?0:i,s=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments);if(0==s)return!1;var c=s.wrappees,u=s.width,p=a()(s,["wrappees","width"]);if(Array.isArray(c)&&c.length>0){var h=c.filter((function(t){return"clear"==t.type}));if(h.length)return this.nextAvailableSpace(Xt({},t,{y:Math.max.apply(Math,h.map((function(t){return t.y})))}));var l=this.mergeWrappees([].concat(c,[{x:u}])).map((function(t){return t.x2=t.x+t.width,t})).map((function(t,e,n){return t.x-(e>0?n[e-1].x2:0)})),d=Math.max.apply(Math,l)>=r;if(!d){var f=c.filter((function(t){return null!=t.y}));return f?this.nextAvailableSpace(Xt({},t,{y:Math.min.apply(Math,f.map((function(t){return t.y})))})):this.nextAvailableSpace(Xt({},t,{height:o+10}))}}return p.y==this.currentY&&delete p.y,Xt({wrappees:c,width:u},p)}},{key:"appendComposed",value:function(){var t=x()(b()(e.prototype),"appendComposed",this).apply(this,arguments);return!1===t&&this.recomposing4Anchor&&!this.recomposing4Anchor.anchored?Frame.IMMEDIATE_STOP:t}},{key:"isAnchored",value:function(t){var n=x()(b()(e.prototype),"isAnchored",this).call(this,t);return this.recomposing4Anchor&&this.recomposing4Anchor.anchor==t&&(this.recomposing4Anchor.anchored=!0),n}},{key:"appendLine",value:function(t){if(!t.props.anchor){if(null!=t.props.composedAt){var n=t.props.composedAt-this.currentY;if(!(this.currentColumn.children.length>0)){var r=t.props,i=r.height,o=r.width,s=r.pagination;return x()(b()(e.prototype),"appendLine",this).call(this,P.a.createElement(yt,{width:o,height:i+n,pagination:s},P.a.createElement(yt,{y:n},t)))}var a=this.currentColumn.children.pop();this.currentColumn.children.push(P.a.cloneElement(a,{height:a.props.height+n}))}return x()(b()(e.prototype),"appendLine",this).apply(this,arguments)}var c={composed:[].concat(this.computed.composed),columns:this.columns.reduce((function(t,e){return[].concat(t,[Xt({},e,{children:[].concat(e.children)})])}),[])},u=t.props.anchor(this,t),p=u.props,h=p.wrap,l=p.geometry,d=p["data-content"];try{if(!h)return 1;if(!this.isDirtyIn(l))return 1;try{return this.recomposing4Anchor=c,this.recomposing4Anchor.anchor=d,this.recompose(),this.recomposing4Anchor.anchored?1:(this.computed.composed=this.recomposing4Anchor.composed,this.columns=this.recomposing4Anchor.columns,this.recompose(),!1)}finally{delete this.recomposing4Anchor}}finally{this.appendComposed(u)}}},{key:"rollbackLines",value:function(t){var n=this,r=(!(arguments.length>1&&void 0!==arguments[1])||arguments[1],x()(b()(e.prototype),"rollbackLines",this).apply(this,arguments));if(r.anchors){var i=r.anchors,o=function(t){var e=t.x,n=void 0===e?0:e,r=t.y,i=void 0===r?0:r,o=t.width,s=t.height,a=(t.wrap,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return Xt({x:n,y:i,width:o,height:s},a)},s=!!i.find((function(t){if(!t.props.wrap)return!1;var e=o(t.props);return!!n.columns.find((function(t){return n.isIntersect(e,o(t,{height:t.height-t.availableHeight}))}))}));s&&this.recompose()}return r}},{key:"mergeWrappees",value:function(t){var e=[].concat(t).sort((function(t,e){return t.x-e.x}));if(e.length<2)return e;e.forEach((function(t){return t.x2=t.x+t.width}));for(var n=[],r=0;r<e.length;){for(var i=e[r],o=i.x,s=i.x2,a=++r;a<e.length;a++,r++){var c=e[a];if(!(c.x<=s))break;s=Math.max(c.x2,s)}n.push({x:o,width:s-o})}return n}}]),e}(Qt);h()(Vt,"AnchorWrappable",Vt);var Kt=Vt;function Jt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Zt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Jt(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var $t=W(M.dom.Unknown),te=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return this.context.parent.appendComposed(this.createComposed2Parent()),null}},{key:"createComposed2Parent",value:function(){var t=this.context.Measure,e=this.props,n=e.fonts,r=e.size,i=e.bold,o=e.italic,s=e.End,a=void 0===s?"":s,c=new t({fonts:n,size:r,bold:i,italic:o});return P.a.createElement(kt,lt()({},c.defaultStyle,{width:c.stringWidth(a),minWidth:0,children:[a],className:"ender"}))}}]),e}($t);h()(te,"propTypes",Zt({},$t.propsTypes,{End:E.a.string})),h()(te,"contextTypes",Zt({},$t.contextTypes,{Measure:E.a.func}));var ee=function(t){function e(t){var n,r=t.width,i=t.maxWidth,o=t.height,s=t.wrappees,a=void 0===s?[]:s,c=t.y;return d()(this,e),(n=g()(this,b()(e).apply(this,arguments))).maxWidth=i,n.content=[],n.wrappees=a,n.composedAt=c,Object.defineProperties(u()(n),{height:{enumerable:!0,configurable:!0,get:function(){return this.content.reduce((function(t,e){var n=e.props.height;return Math.max(t,n)}),0)}},children:{enumerable:!0,configurable:!0,get:function(){return this.content}},availableHeight:{enumerable:!1,configurable:!1,get:function(){return o}},availableWidth:{enumerable:!1,configurable:!1,get:function(){return r-this.currentX}},currentX:{enumerable:!1,configurable:!1,get:function(){return this.content.reduce((function(t,e){var n=e.props,r=n.width,i=n.x;return null!=i?i+r:t+r}),0)}},width:{enumerable:!0,configurable:!1,get:function(){return r}},first:{enumerable:!1,configurable:!1,get:function(){var t=this.content.find((function(t){return void 0===t.props.x}));return t&&t.props.atom?t.props.atom:t&&null==t.props.descent?t.props.children:t}},last:{enumerable:!1,configurable:!1,get:function(){var t=this.content.findLast((function(t){return void 0===t.props.x}));return t&&t.props.atom?t.props.atom:t}},paragraph:{enumerable:!1,configurable:!1,get:function(){return this.context.parent}}}),n}return k()(e,t),y()(e,[{key:"isEmpty",value:function(){return!this.first}},{key:"hasEqualSpace",value:function(t){t.width;var e=t.maxWidth,n=t.wrappees,r=void 0===n?[]:n;return this.props.maxWidth==e&&this.wrappees.length==r.length&&!this.wrappees.find((function(t,e){var n=r[e];return Math.abs(t.x-n.x)>1&&Math.abs(t.width-n.width)>1}))}},{key:"appendComposed",value:function(t,e){var n=this,r=t.props,i=r.width,o=r.minWidth,s=void 0===o?parseInt(i):o,a=r.anchor;if(!a){var c=function(){return 0==s||0==n.content.length||n.availableWidth>=s||n.availableWidth==n.maxWidth};if(c()){if(this.wrappees=this.wrappees.map((function(t,e){if(!(n.currentX+s>t.x))return t;n.content.push(P.a.createElement(yt,lt()({},t,{height:0}))),n.wrappees[e]=null})).filter((function(t){return!!t})),c()){var u=this.lineHeight();this.content.push(t);var p=this.lineHeight();if(u!=p){var h=this.context.parent.nextAvailableSpace({height:p,y:this.composedAt}),l=h.wrappees,d=h.y;if(this.composedAt=d,l&&l.length>0&&this.shouldRecompose(l))return e=e-this.content.reduce((function(t,e){return null==e.props.x?t+1:t}),0)+1,this.required={height:p},e}return}return!!this.isEmpty()&&(this.content.push(t),this.required={width:s,height:this.lineHeight()},e)}return!1}var f=new M.ReactQuery(t).findFirst('[data-type="anchor"]'),y=f.attr("data-content");if(this.content.push(P.a.cloneElement(f.get(0),{atom:t})),!this.context.parent.context.isAnchored(y))return this.anchor=a,!1}},{key:"lineHeight",value:function(){return this.paragraph.lineHeight(this.height)}},{key:"shouldRecompose",value:function(t){var e=this;t=this.mergeWrappees(t);var n=this.content.filter((function(t){return void 0!==t.props.x}));if(n.reduce((function(e,n,r){var i=n.props,o=i.x,s=i.width;if(e){var a=t[r];return!!a&&0==parseInt(Math.abs(a.x-o))&&a.width==s}return!1}),!0)){var r=t.slice(n.length);return r.slice(0,1).reduce((function(t,n){return n.x<e.currentX}),!1)?(this.wrappees=t,!0):(this.wrappees=r,!1)}return this.wrappees=t,!0}},{key:"mergeWrappees",value:function(t){var e=[].concat(this.wrappees,t).sort((function(t,e){return t.x-e.x}));if(e.length<2)return e;e.forEach((function(t){return t.x2=t.x+t.width}));for(var n=[],r=0;r<e.length;){for(var i=e[r],o=i.x,s=i.x2,a=++r;a<e.length;a++,r++){var c=e[a];if(!(c.x<=s))break;s=Math.max(c.x2,s)}n.push({x:o,width:s-o})}return n}},{key:"commit",value:function(){var t=this;return this.wrappees.forEach((function(e){return t.content.push(P.a.createElement(yt,lt()({},e,{height:0})))})),this.wrappees=[],this}}]),e}(C.Component),ne=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"getMerged",it()((function(t){return P.a.Children.toArray(t).reduce((function(t,e,n){var r=re(e);return r.bText?r.join(",")==t.trunkPath?t.trunk.push(e):(t.mergeTrunk(n),t.trunk.push(e),t.trunkPath=r.join(",")):(t.mergeTrunk(n),t.pieces.push(P.a.cloneElement(e,{x:t.x,key:n})),t.x+=e.props.width),t}),{pieces:[],x:0,trunk:[],trunkPath:null,mergeTrunk:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(1==this.trunk.length){var e=this.trunk[0];this.pieces.push(P.a.cloneElement(e,{x:this.x,key:t})),this.x+=e.props.width}else if(this.trunk.length>1){var n=function(t){return re(t,(function(t){return t})).pop()},r=this.trunk.map(n),i=r.reduce((function(t,e){return t.width+=e.props.width,t.children+=e.props.children,t}),{width:0,children:"","data-endat":r[r.length-1].props["data-endat"],className:void 0,minWidth:void 0}),o=re(this.trunk[0],(function(t){return t}),(function(t){return!0})).slice(0,-1),s=o.reduceRight((function(t,e){return P.a.cloneElement(e,{width:i.width},t)}),P.a.cloneElement(r[0],i));this.pieces.push(P.a.cloneElement(s,{x:this.x,key:t})),this.x+=i.width}return this.trunk=[],this.trunkPath=null,this}}).mergeTrunk().pieces}))),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=a()(t,["children"]);return P.a.createElement(yt,n,this.getMerged(e))}}]),e}(C.Component);function re(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return t.props["data-content"]},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(t){return!!t.props["data-content"]},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return P.a.isValidElement(t)&&(n(t)&&(r.push(e(t)),r.bText="text"==t.props["data-type"]),P.a.isValidElement(t.props.children)&&re(P.a.Children.only(t.props.children),e,n,r)),r}var ie=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.align,r=void 0===n?"left":n,i=e.reduce((function(t,e){var n=e.props,r=n.height,i=n.descent,o=void 0===i?0:i;return Math.max(t,r-o)}),0),o=this[r](),s=e.find((function(t){return"ender"==t.props.className}));if(s){var a=o[o.length-1].props.children;if(a.length>0){var c=a[a.length-1].props,u=c.x,p=void 0===u?0:u,h=c.width,l=void 0===h?0:h;a.push(P.a.cloneElement(s,{key:"ender",x:p+l}))}else a.push(P.a.cloneElement(s,{key:"ender"}))}return P.a.createElement(yt,{className:"story",baseline:i,children:this.baseline(o,i)})}},{key:"baseline",value:function(t,e){return function t(n){return"story"==n.props.className?n:n.type==kt?P.a.cloneElement(n,{y:e}):Array.isArray(n.props.children)?P.a.cloneElement(n,{children:n.props.children.reduce((function(e,n,r){return e[r]=t(n),e}),[])}):n.props.children?P.a.cloneElement(n,{children:t(n.props.children)}):n}(P.a.createElement(yt,{children:t})).props.children}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.props.children.filter((function(t){return"ender"!=t.props.className})).reduce((function(e,n){return null!=n.props.x?t?e.push({located:n,words:[]}):(e[e.length-1].located=n,e.push({words:[]})):e[e.length-1].words.push(n),e}),[{words:[]}]).map((function(t){var e=t.words.length-Array.from(t.words).reverse().findIndex((function(t){return!oe(t)}));return t.endingWhitespaces=t.words.slice(e),t.words=t.words.slice(0,e),t}))}},{key:"left",value:function(){return this.group().reduce((function(t,e){var n=e.words,r=e.endingWhitespaces,i=e.located;return t.aligned.push(P.a.cloneElement(new ne({x:t.x,children:[].concat(n,r).map((function(t,e){return P.a.cloneElement(t,{key:e})}))}).render(),{key:t.aligned.length})),i&&(t.aligned.push(P.a.cloneElement(i,{key:t.aligned.length})),t.x=i.props.x+i.props.width),t}),{x:0,aligned:[]}).aligned}},{key:"right",value:function(){return this.group(!0).reduceRight((function(t,e){var n=e.located,r=e.words,i=e.endingWhitespaces;return i.length>0&&t.aligned.push(P.a.cloneElement(new ne({x:t.x,children:i.map((function(t,e){return P.a.cloneElement(t,{key:e})}))}).render(),{key:t.aligned.length})),t.x=r.reduce((function(t,e){return t-e.props.width}),t.x),t.aligned.push(P.a.cloneElement(new ne({x:t.x,children:r.map((function(t,e){return P.a.cloneElement(t,{key:e})}))}).render(),{key:t.aligned.length})),n&&(t.aligned.push(P.a.cloneElement(n,{key:t.aligned.length})),t.x=n.props.x),t}),{x:this.props.width,aligned:[]}).aligned.reverse()}},{key:"center",value:function(){var t=this;return this.group().reduce((function(e,n){var r=n.words,i=n.endingWhitespaces,o=n.located,s=(o?o.props.x:t.props.width)-e.x,a=r.reduce((function(t,e){return t+e.props.width}),0);return e.aligned.push(P.a.cloneElement(new ne({x:e.x+(s-a)/2,children:r.concat(i).map((function(t,e){return P.a.cloneElement(t,{key:e})}))}).render(),{key:e.aligned.length})),o&&(e.aligned.push(P.a.cloneElement(o,{key:e.aligned.length})),e.x=o.props.x+o.props.width),e}),{x:0,aligned:[]}).aligned}},{key:"justify",value:function(){var t=this;return this.group().reduce((function(e,n){var r=n.words,i=n.endingWhitespaces,o=n.located,s=e.justified.length,a=(o?o.props.x:t.props.width)-e.x,c=r.reduce((function(t,e,n){return oe(e)?t.whitespaces.push(n):t.contentWidth+=e.props.width,t}),{contentWidth:0,whitespaces:[]}),u=c.whitespaces,p=c.contentWidth,h=u.length>0?(a-p)/u.length:0;return r.concat(i).reduce((function(t,n,r){return e.justified.push(P.a.cloneElement(n,{x:t,key:s++})),t+(u.includes(r)?h:n.props.width)}),e.x),o&&(e.justified.push(P.a.cloneElement(o,{key:s++})),e.x=o.props.x+o.props.width),e}),{x:0,justified:[]}).justified}},{key:"both",value:function(){return this.justify()}}]),e}(C.Component);function oe(t){return new M.ReactQuery(t).findFirst(".whitespace").length>0}function se(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ae(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?se(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):se(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(ie,"displayName","story");var ce=F(M.dom.Paragraph),ue=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).computed.lastText="",t.computed.atoms=[],t.computed.needMerge=!1,t.computed.hasFrame=!1,t}return k()(e,t),y()(e,[{key:"hasFrame",value:function(){return this.computed.hasFrame}},{key:"getBreakOpportunities",value:function(t,e){var n=this.computed.lastText;if(!t)return null===t&&(this.computed.lastText=""),e&&(this.computed.hasFrame=!0),[];if(" "==t)return this.computed.lastText="",[t];var r=Nt("".concat(n).concat(t));if(!n)return this.computed.lastText=r[r.length-1]||"",r;var i=Nt(n),o=i.length-1,s=r.slice(o);return""==(s[0]=s[0].substring(i.pop().length))?s.splice(0,1):this.computed.needMerge=!0,this.computed.lastText=s[s.length-1]||"",s}},{key:"getChildContext",value:function(){return ae({},x()(b()(e.prototype),"getChildContext",this).call(this),{getMyBreakOpportunities:this.getBreakOpportunities.bind(this)})}},{key:"createLine",value:function(t){var e,n,r,i,o,s,c,u,p,h,l=this,d=this.context.parent.nextAvailableSpace(t),f=d.width,y=a()(d,["width"]),m=(e=f,n=l.props,r=n.indent,i=r.left,o=void 0===i?0:i,s=r.right,c=void 0===s?0:s,u=r.firstLine,p=void 0===u?0:u,h=n.numbering,e-=o+c,0==l.computed.composed.length&&(h||(e-=p)),e),g=new this.constructor.Line(ae({},y,{width:m}),{parent:this});return this.computed.composed.push(g),g}},{key:"children",value:function(){return[].concat(C.Children.toArray(this.props.children),[this.createEnder()])}},{key:"createEnder",value:function(){return P.a.createElement(this.constructor.End,lt()({},this.props.defaultStyle,{End:"",key:"".concat(this.props.id,"-end"),id:"".concat(this.props.id,"-end")}))}},{key:"appendComposed",value:function(t){if(this.computed.needMerge){var e=this.computed.atoms.pop(),n=Math.max(e.props.height,t.props.height),r=Math.max(e.props.descent,t.props.descent),i=e.props.width+t.props.width;return this.computed.atoms.push(P.a.createElement(yt,{width:i,height:n,descent:r},e,P.a.cloneElement(t,{x:e.props.width}))),void(this.computed.needMerge=!1)}this.computed.atoms.push(t)}},{key:"onAllChildrenComposed",value:function(){this.commit(),x()(b()(e.prototype),"onAllChildrenComposed",this).call(this)}},{key:"rollbackLines",value:function(t){this.computed.composed.splice(-t)}},{key:"commit",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_SAFE_INTEGER,r=this.context.parent,i=this.computed.atoms,o=function(e){var n=t.computed,r=n.composed,i=n.atoms,o=r.findIndex((function(t){return i.indexOf(t.first)==e}));t.rollbackLines(r.length-o)},s=function(e){return r.appendComposed(t.createComposed2Parent(t.currentLine.commit(),e))},a=function(e){return i.indexOf(t.computed.composed[t.computed.composed.length-e].first)},c=this.computed.atoms.length,u=5,p=0;this.createLine();var h=function e(){for(var r,h,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,d=0,f=0,y=l;y<c;){if(y>n)return;if(y==d){if(++f>u)throw Error("it may be dead loop on ".concat(y,"th atoms"))}else d=y,f=0;if(r=t.currentLine.appendComposed(i[y],y),Number.isInteger(r)){var m=t.currentLine;t.rollbackLines(1),t.createLine(m.required),y=r}else{if(!1===r){if(!Number.isInteger(h=s(!1))){t.createLine();continue}if(h==Kt.IMMEDIATE_STOP)return Kt.IMMEDIATE_STOP;if(r=a(h),Number.isInteger(r)){o(r),t.createLine(),y=r;continue}}y++}}if(++p>u)console.error("it may be dead loop on since commit nested ".concat(p,", ignore and continue"));else if((1==t.computed.composed.length||!t.currentLine.isEmpty())&&(h=s(!0),Number.isInteger(h))){if(h==Kt.IMMEDIATE_STOP)return Kt.IMMEDIATE_STOP;r=a(h),o(r),t.createLine(),e(r)}};return h(e)}},{key:"recommit",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.computed.composed,e=this.computed,n=e.atoms,r=e.composed;t=r.slice(-t.length),this.rollbackLines(t.length);var i=n.findIndex((function(e){return e==t[0].first})),o=n.slice(i+1).findIndex((function(e){return e==t[t.length-1].last}))+i+1;return this.commit(i,o)}},{key:"lineHeight",value:function(t){var e=this.props.spacing,n=e.lineHeight,r=void 0===n?"100%":n,i=e.top,o=void 0===i?0:i;e.bottom;return r="string"==typeof r?Math.ceil(t*parseInt(r)/100):r,1==this.computed.composed.length&&(r+=o),r}},{key:"getNumberingAtom",value:function(){var t=this.props,e=t.numbering,n=e.style,r=e.label,i=t.indent.firstLine,o=void 0===i?0:i,s=new this.context.Measure(n).defaultStyle;return P.a.createElement(kt,lt()({},s,{className:"numbering",width:-o,children:r}))}},{key:"createComposed2Parent",value:function(t,e){var n=t.height,r=t.width,i=t.children,o=t.anchor,s=t.composedAt,a=t.currentX,c=[].concat(i),u=a,p=0,h=this.props,l=h.spacing,d=l.lineHeight,f=void 0===d?"100%":d,y=l.top,m=void 0===y?0:y,g=l.bottom,v=void 0===g?0:g,b=h.indent,w=b.left,x=void 0===w?0:w,O=(b.right,b.firstLine),k=void 0===O?0:O,C=h.align,j=h.orphan,E=h.widow,S=h.keepWithNext,A=h.keepLines,M=0,D=x;if(1==this.computed.composed.length&&(p+=m,M+=m,D+=k,this.props.numbering)){var I=this.getNumberingAtom();c.unshift(I),n=Math.max(n,I.props.height),u+=I.props.width,r+=I.props.width}e&&(p+=v,"justify"!=C&&"both"!=C||(C=void 0)),f=("string"==typeof f?n*parseInt(f)/100:f)+p;var T={orphan:j,widow:E,keepWithNext:S,keepLines:A,i:this.computed.composed.length,last:e};return P.a.createElement(yt,{height:f,width:D+r,className:"line",pagination:T,anchor:o,composedAt:s},P.a.createElement(yt,{x:D,y:M,width:r,height:n},new this.constructor.Story({children:c,align:C,width:r,contentWidth:u}).render()))}},{key:"enderWidth",get:function(){return this.computed.atoms[this.computed.atoms.length-1].props.width}},{key:"currentLine",get:function(){var t=this.computed.composed;return 0==t.length&&this.createLine(),t[t.length-1]}}]),e}(ce);function pe(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function he(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?pe(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pe(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(ue,"Line",ee),h()(ue,"Story",ie),h()(ue,"End",te),h()(ue,"contextTypes",ae({},ce.contextTypes,{Measure:E.a.func})),h()(ue,"childContextTypes",ae({},ce.childContextTypes,{getMyBreakOpportunities:E.a.func}));var le=M.dom.Text,de=W(le),fe=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"createMeasure",it()((function(t,e,r,i){var o=new(0,n.context.Measure)({fonts:t,size:e,bold:r,italic:i}),s=o.stringWidth.bind(o),a=new Map;return o.stringWidth=function(t){if(a.has(t))return a.get(t);var e=s(t);return a.set(t,e),e},o}))),n}return k()(e,t),y()(e,[{key:"getMyBreakOpportunities",value:function(){return this.context.getMyBreakOpportunities(this.text)}},{key:"render",value:function(){var t=this;if(this.props.vanish)return null;var e=this.measure,n=this.defaultStyle,r=e.stringWidth(" "),i=0;return this.getMyBreakOpportunities().forEach((function(o){o.split(/(\s)/).filter((function(t){return!!t})).forEach((function(o,s){var a=" "==o,c=!!o.endsWith(",")&&o.substring(0,o.length-1);t.appendComposed(he({},n,{className:a?"whitespace":void 0,width:a?r:e.stringWidth(o),minWidth:a?0:c?e.stringWidth(c):void 0,"data-endat":i+=o.length,children:o}))}))})),this.onAllChildrenComposed(),null}},{key:"createComposed2Parent",value:function(t){var e=P.a.createElement(kt,t);return this.computed.composed.push(e),e}},{key:"text",get:function(){var t=this.props.children,e=void 0===t?"":t;return Array.isArray(e)?e.join(""):e}},{key:"measure",get:function(){var t=this.props,e=t.fonts,n=t.size,r=t.bold,i=t.italic;return this.createMeasure(e,n,r,i)}},{key:"defaultStyle",get:function(){var t=this.props,e=t.color,n=t.highlight,r=(t.vanish,t.border),i=t.underline,o=t.strike;return he({},this.measure.defaultStyle,{color:e,highlight:n,border:r,underline:i,strike:o})}}]),e}(de);h()(fe,"contextTypes",he({},de.contextTypes,{Measure:E.a.func,getMyBreakOpportunities:E.a.func}));var ye=n(22),me=n.n(ye),ge=n(23),ve=n.n(ge),be=n(24),we=n.n(be),xe=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"toString",value:function(){var t=this;return this.__evaluateStack(),it()((function(n){return x()(b()(e.prototype),"toString",t).call(t)}))(this.segments.map((function(t){return t.join("")})).join(""))}},{key:"bounds",value:function(){return this.contour().reduce((function(t,e){var n=t.left,r=t.top,i=t.right,o=t.bottom,s=nt()(e,2),a=s[0],c=s[1];return{left:Math.min(n,a),top:Math.min(r,c),right:Math.max(i,a),bottom:Math.max(o,c)}}),{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER})}},{key:"contour",value:function(){var t=this;arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.toString();return it()((function(e,n){return we()(t.segments).map((function(t){return t.map((function(t){var e=nt()(t,2),n=e[0],r=e[1];return[Math.ceil(n),Math.ceil(r)]}))})).map((function(t){return ve()(t,e)})).reduce((function(t,e){return[].concat(t,e)}),[])}))()}},{key:"intersects",value:function(t,e){var n=this.contour(e);return n.slice(1).map((function(t,e){var r=nt()(t,2),i=r[0],o=r[1],s=nt()(n[e],2);return{x1:s[0],y1:s[1],x2:i,y2:o}})).map((function(e){return function(t,e){var n=t.x1,r=t.x2,i=e.x1,o=e.x2,s=t.y1,a=t.y2,c=e.y1,u=e.y2,p=(n-r)*(c-u)-(s-a)*(i-o),h=(n*a-s*r)*(i-o)-(n-r)*(i*u-c*o),l=(n*a-s*r)*(c-u)-(s-a)*(i*u-c*o);if(0==p);else{var d={x:h/p,y:l/p};if(Oe(d.x,n,r)&&Oe(d.y,s,a)&&Oe(d.x,i,o)&&Oe(d.y,c,u))return d}}(e,t)})).filter((function(t){return!!t}))}},{key:"center",value:function(){var t=this.bounds(),e=t.left,n=t.right,r=t.top,i=t.bottom,o=t.x,s=void 0===o?(e+n)/2:o,a=t.y;return{x:s,y:void 0===a?(r+i)/2:a}}},{key:"clone",value:function(){return new this.constructor(this.toString())}},{key:"size",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.bounds(),n=e.left,r=e.right,i=e.top,o=e.bottom,s=e.width,a=void 0===s?r-n:s,c=e.height,u=void 0===c?o-i:c;return{width:a+t,height:u+t}}}],[{key:"fromRect",value:function(t){var e=t.x,n=t.y,r=t.width,i=t.height;return new this("M".concat(e," ").concat(n," h").concat(r," v").concat(i," h").concat(-r,"z"))}}]),e}(me.a),Oe=function(t,e,n){return t>=e&&t<=n||t>=n&&t<=e};function ke(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ce(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ke(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ke(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Pe=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"availableSpace",value:function(){return this.contentBox}},{key:"createComposedShape",value:function(t){var e=this.props,n=e.margin,r=n.left,i=void 0===r?0:r,o=n.top,s=void 0===o?0:o,a=e.solidFill,c=void 0===a?"transparent":a,u=e.blipFill,p=(u=void 0===u?{}:u).url,h=e.outline,l=void 0===h?{width:0}:h,d=e.fill,f=void 0===d?{fill:c}:d,y=[];return y.push(P.a.createElement(yt,{x:this.strokeWidth/2,y:this.strokeWidth/2,key:"outline"},P.a.createElement("path",{d:this.getPath().toString(),style:Ce({strokeWidth:this.strokeWidth,stroke:l.solidFill},f)}))),p&&y.push(P.a.createElement(yt,{x:this.strokeWidth+i,y:this.strokeWidth+s,key:"background"},P.a.createElement("image",Ce({},this.contentBox,{xlinkHref:p,preserveAspectRatio:"none"})))),t&&y.push(P.a.createElement(yt,{key:"content",x:this.strokeWidth+i,y:this.strokeWidth+s},t)),P.a.createElement(yt,lt()({},this.outlineBox,{geometry:this.getPath().clone()}),y)}},{key:"getPath",value:function(){return it()((function(t){return new xe(t)}))(this.props.geometry)}},{key:"strokeWidth",get:function(){var t=this.props.outline,e=(t=void 0===t?{}:t).width;return(void 0===e?0:e)||0}},{key:"contentBox",get:function(){var t=this.props.margin,e=t.right,n=void 0===e?0:e,r=t.left,i=void 0===r?0:r,o=t.top,s=void 0===o?0:o,a=t.bottom,c=void 0===a?0:a,u=this.getPath().size(),p=u.width,h=u.height,l=this.strokeWidth;return{width:p-l/2-n-i,height:h-l/2-s-c}}},{key:"outlineBox",get:function(){return this.getPath().size(this.strokeWidth)}}]),e}(C.Component),je=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getPath",value:function(){var t=this.props,e=t.width,n=t.height;return new xe("M0 0h".concat(e,"v").concat(n,"h").concat(-e,"z"))}}]),e}(Pe),Ee=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getPath",value:function(){var t=this.props,e=t.width,n=t.height,r=t.cx,i=void 0===r?e/2:r,o=t.cy,s=void 0===o?n/2:o,a=t.rx,c=void 0===a?i:a,u=t.ry,p=void 0===u?s:u;return new xe("M".concat(i-c,",").concat(s,"a").concat(c,",").concat(p," 0 1,0 ").concat(2*c,",0a").concat(c,",").concat(p," 0 1,0 -").concat(2*c,",0"))}}]),e}(Pe),Se=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),e}(Ee);function Ae(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Me(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ae(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ae(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var De=at(F(M.dom.Shape)),Ie=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return this.context.getMyBreakOpportunities&&this.context.getMyBreakOpportunities(null,!0),x()(b()(e.prototype),"render",this).call(this)}},{key:"create",value:function(){for(var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this.geometry.availableSpace(),i=r.width,o=(r.height,arguments.length),s=new Array(o>1?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];return(t=x()(b()(e.prototype),"create",this)).call.apply(t,[this,Me({},n,{width:i,height:Number.MAX_SAFE_INTEGER})].concat(s))}},{key:"createComposed2Parent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.current.render();return this.transform(this.geometry.createComposedShape(t))}},{key:"transform",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.props.geometry,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.geometry.strokeWidth,r=this.props,i=r.rotate,o=r.scale,s={};if(i){var a=e.center(),c=a.x,u=a.y,p=e.bounds();e.rotate(i,c,u),i="".concat(i," ").concat(c," ").concat(u);var h=e.bounds();s.x=parseInt(p.left-h.left),s.y=parseInt(p.top-h.top),e.translate(s.x,s.y),e.origin={x:s.x,y:s.y}}o&&e.scale(o),e.strokeWidth=n;var l=e.size(n),d=l.width,f=l.height;return P.a.createElement(yt,{width:d,height:f,geometry:e},P.a.createElement(yt,Me({scale:o,rotate:i},s),t))}},{key:"onAllChildrenComposed",value:function(){this.context.parent.appendComposed(this.createComposed2Parent()),x()(b()(e.prototype),"onAllChildrenComposed",this).call(this)}},{key:"geometry",get:function(){var t=this;return it()((function(){var e=t.props.geometry,n=void 0===e?"rect":e;return new(t.constructor[n]||t.constructor.custom)(t.props,t.context)}))()}}]),e}(De);function Te(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(Ie,"fissureLike",(function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getComposeType",value:function(){return Ie.getType()}},{key:"render",value:function(){if(this.isEmpty())return null;var t=this.props,n=t.I,r=t.width,i=t.height,o=t.margin;return P.a.cloneElement(x()(b()(e.prototype),"createComposed2Parent",this).call(this),{key:n,width:r,height:i,margin:o})}}]),e}(t),h()(e,"dispatchName","frame-shape"),n})),h()(Ie,"contextTypes",Me({},De.contextTypes,{getMyBreakOpportunities:E.a.func})),h()(Ie,"custom",Pe),h()(Ie,"rect",je),h()(Ie,"ellipse",Ee),h()(Ie,"circle",Se);var Le=M.dom.Image,Re=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getShape",value:function(){var t=this.props,e=t.width,n=t.height;return new Ie(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Te(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Te(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({width:e,height:n},this.props.outline,{margin:{},children:null}),this.context)}},{key:"createComposed2Parent",value:function(){var t=this.getShape(),e=t.geometry.contentBox,n=e.width,r=e.height,i=this.props.src,o=P.a.createElement(Ct,{width:n,height:r,xlinkHref:i,preserveAspectRatio:"none"});return t.createComposed2Parent(o)}}]),e}(W(Le));function Fe(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ne(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Fe(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fe(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var We=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"nextAvailableSpace",value:function(){var t,e=(t=this.context.parent).nextAvailableSpace.apply(t,arguments);return Ne({},e,{width:this.props.width})}},{key:"createComposed2Parent",value:function(t){return P.a.createElement(yt,{width:this.props.width,height:t.props.height},P.a.cloneElement(t,{x:this.props.indent}))}}]),e}(F(M.dom.Table));function ze(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var qe,Be,Ye=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).computed.spaces=[],t}return k()(e,t),y()(e,[{key:"cellId",value:function(t){if(t)return new M.ReactQuery(t).findFirst('[data-type="cell"]').attr("data-content")}},{key:"appendComposed",value:function(t){this.currentColumn[0]?this.cellId(this.currentColumn[0])==this.cellId(t)?this.currentColumn.push(t):this.computed.composed.push([t]):this.currentColumn.push(t),this.currentSpace&&this.injectCellIntoRank(t)}},{key:"injectCellIntoRank",value:function(t){var e=this.currentSpace.frame.lastLine;if(e){var n=new M.ReactQuery(e).findFirstAndParents('[data-content="'.concat(this.props.id,'"]')),r=n.first,i=n.parents;if(!r.length)return;var o=r.attr("children");o[this.computed.composed.length-1]=t;var s=this.getHeight(o);if(s>r.attr("height")){var a=i.reduceRight((function(t,e){return P.a.cloneElement(e,{height:s},t)}),P.a.cloneElement(r.get(0),{height:s}));this.currentSpace.frame.currentColumn.children.splice(-1,1,a)}}}},{key:"nextAvailableSpace",value:function(t){var n,r,i=t.height,o=void 0===i?0:i,s=t.id,a=this.props.cols;if(this.currentColumn[0])if(this.cellId(this.currentColumn[0])==s){if(this.ranks<this.currentColumn.length+1){var c=this.createComposed2Parent();1==this.context.parent.appendComposed(c)&&1==this.context.parent.appendComposed(c)&&console.error("row[".concat(this.props.id,"] can't be appended with rollback again, ignore"));var u=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments);this.computed.spaces.push(u),n=u.height}else(n=this.computed.spaces[this.currentColumn.length].height)<o&&(this.computed.spaces[this.currentColumn.length]=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments),n=this.computed.spaces[this.currentColumn.length].height);r=a[this.computed.composed.length-1].width}else(n=this.computed.spaces[0].height)<o&&(this.computed.spaces[0]=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments),n=this.computed.spaces[0].height),r=a[this.computed.composed.length].width;else{var p=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments);this.computed.spaces=[p],n=p.height,r=a[0].width}return this.props.keepLines&&(n=Number.MAX_SAFE_INTEGER),{width:r,height:n}}},{key:"injectEmptyCellIntoRank",value:function(t,e){var n=this,r=t.attr("height"),i=t.attr("children");i.splice.apply(i,[i.length,0].concat(new Array(this.props.cols.length-i.length).fill(null))),i.forEach((function(t,e){i[e]=t||P.a.cloneElement(n.computed.composed[e][0],{height:r,frame:void 0})})),i.forEach((function(t,e){var n=new M.ReactQuery(t).findFirstAndParents('[data-type="cell"]'),o=n.first,s=n.parents;i[e]=s.reduceRight((function(t,e){return P.a.cloneElement(e,{height:r},t)}),P.a.cloneElement(o.get(0),{height:r}))}))}},{key:"onAllChildrenComposed",value:function(){var t=this;!function(){for(var e=t.ranks-t.currentColumn.length,n=e;n>0;n--)t.currentColumn.push(null);var r=t.createComposed2Parent(!0);1==t.context.parent.appendComposed(r)&&1==t.context.parent.appendComposed(r)&&console.error("row[".concat(t.props.id,"] can't be appended with rollback again, ignore")),e>0&&t.currentColumn.splice(-e)}(),this.computed.spaces.forEach((function(e){var n=e.frame,r=new M.ReactQuery(n.lastLine).findFirstAndParents('[data-content="'.concat(t.props.id,'"]')),i=r.first,o=r.parents;if(!i.length)throw new Error("weired table row without rank");t.injectEmptyCellIntoRank(i,o,n)})),x()(b()(e.prototype),"onAllChildrenComposed",this).call(this)}},{key:"createComposed2Parent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.props.cols,n=this.width,r=this.computed.composed,i=this.currentColumn.length-1,o=r.map((function(t){return t[i]})),s=this.getHeight(o);return P.a.createElement(He,{children:o,cols:e,width:n,height:s,last:t})}},{key:"getHeight",value:function(t){return Math.max.apply(Math,[this.props.height||0].concat(t.filter((function(t){return!!t})).map((function(t){return t.props.nonContentHeight+t.props.frame.currentY}))))}},{key:"width",get:function(){return this.closest("table").props.width}},{key:"currentColumn",get:function(){return 0==this.computed.composed.length&&this.computed.composed.push([]),this.computed.composed[this.computed.composed.length-1]}},{key:"ranks",get:function(){return this.computed.composed.reduce((function(t,e){return Math.max(t,e.length)}),0)}},{key:"currentSpace",get:function(){return this.computed.spaces[this.currentColumn.length-1]}}]),e}(F(M.dom.Row)),He=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=void 0===e?[]:e,r=t.cols,i=t.height,o=(t.last,a()(t,["children","cols","height","last"]));return P.a.createElement(yt,lt()({height:i},o),n.map((function(t,e){return P.a.cloneElement(t,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ze(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ze(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},r[e],{height:i,key:e}))})))}}]),e}(C.PureComponent);function _e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ge(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?_e(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_e(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(He,"displayName","rank");var Qe=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"create",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.computed.composed.length>0&&(this.current.isEmpty()?this.computed.composed.pop():this.context.parent.appendComposed(this.createComposed2Parent()));var i=this.context.parent.nextAvailableSpace(Ge({},r,{id:this.props.id})),o=i.height,s=i.width,a=this.props,c=a.margin,u=void 0===c?{right:0,left:0,top:0,bottom:0}:c,p=a.vertAlign;return x()(b()(e.prototype),"create",this).call(this,{width:s-u.right-u.left,height:o-this.nonContentHeight,vertAlign:p})}},{key:"onAllChildrenComposed",value:function(){this.context.parent.appendComposed(this.createComposed2Parent()),x()(b()(e.prototype),"onAllChildrenComposed",this).call(this)}},{key:"createComposed2Parent",value:function(){var t=this.props,e=t.border,n=t.margin,r=t.background,i=t.vertAlign,o=(this.current.currentY,this.nonContentHeight,this.current.props.width+n.left+n.right);return P.a.createElement(this.constructor.ComposedCell,{border:e,margin:n,background:r,vertAlign:i,width:o,nonContentHeight:this.nonContentHeight,frame:this.current})}},{key:"nonContentHeight",get:function(){var t=this.props,e=t.margin,n=void 0===e?{right:0,left:0,top:0,bottom:0}:e,r=t.border;return r.top.sz+r.bottom.sz+n.top+n.bottom}}]),e}(at(F(M.dom.Cell)));h()(Qe,"fissureLike",(function(t){var e,n;return n=e=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"clone",value:function(t){var n=t.height,r=(a()(t,["height"]),x()(b()(e.prototype),"clone",this).apply(this,arguments));return null!=n&&(this.columns[0].height=n),r}},{key:"getComposeType",value:function(){return Qe.getType()}},{key:"appendLine",value:function(t){var n=t.props.height;return!(n-this.currentColumn.availableHeight>1&&0==this.currentColumn.children.length)&&x()(b()(e.prototype),"appendLine",this).apply(this,arguments)}},{key:"render",value:function(){return P.a.createElement(yt,{children:this.createComposed2Parent().props.children,className:"frame"})}}]),e}(t),h()(e,"displayName","frame-cell"),n}));var Ue=yt;Qe.ComposedCell=(Be=qe=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.border,n=t.margin,r=(t.vertAlign,t.width),i=t.frame,o=t.height,s=(t.nonContentHeight,a()(t,["border","margin","vertAlign","width","frame","height","nonContentHeight"]));return P.a.createElement(yt,lt()({},s,{height:o,width:r}),new Xe({border:e,width:r,height:o,children:P.a.createElement(Ue,{x:n.left,y:n.top},i?i.clone({height:o}).render():null)}).render())}}]),e}(C.PureComponent),h()(qe,"displayName","cell"),Be);var Xe=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.width,n=t.height,r=t.border,i=r.left,o=r.right,s=r.bottom,c=r.top,u=t.children,p=a()(t,["width","height","border","children"]);return P.a.createElement(yt,p,P.a.createElement(yt,{className:"border",children:[P.a.createElement(Ve,{key:"top",type:"top",size:c.sz,color:c.color,d:"M0 0 h".concat(e)}),P.a.createElement(Ve,{key:"bottom",type:"bottom",size:s.sz,color:c.color,d:"M0 ".concat(n," h").concat(e)}),P.a.createElement(Ve,{key:"right",type:"right",size:o.sz,color:c.color,d:"M".concat(e," 0 v").concat(n)}),P.a.createElement(Ve,{key:"left",type:"left",size:i.sz,color:c.color,d:"M0 0 v".concat(n)})]}),P.a.createElement(yt,{x:i.sz/2,y:c.sz/2},u))}}]),e}(C.PureComponent),Ve=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.size,n=t.color,r=t.d;return P.a.createElement("path",{strokeWidth:e,stroke:n,d:r})}}]),e}(C.PureComponent),Ke=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"createComposed2Parent",value:function(t){var e=this,n=t.props,r=n.width,i=n.height,o=n.geometry,s=this.props,a=s.margin,c=(a=void 0===a?{}:a).left,u=void 0===c?0:c,p=a.right,h=void 0===p?0:p,l=a.top,d=void 0===l?0:l,f=a.bottom,y=void 0===f?0:f,m=s.wrap.mode;return this.width=r+=u+h,this.height=i+=d+y,P.a.createElement(yt,{width:0,height:0,anchor:function(n,s){var a=e.xy(n,s),c=a.x,p=a.y;c-=u,p-=d,o&&o.origin&&(c-=o.origin.x,p-=o.origin.y);var h=function(t){if(t)return"Square"==m||"TopAndBottom"==m?function(n){return t.call(e,n,{bounds:function(){return{left:c,top:p,right:c+r,bottom:p+i}}})}:function(n){return t.call(e,n,o.clone().translate(c,p))}}(e["wrap".concat(m)]);return P.a.createElement(yt,{x:c,y:p,wrap:h,geometry:{x:c,y:p,width:r,height:i},"data-content":e.props.id,"data-type":e.getComposeType()},P.a.createElement(yt,{x:u,y:d},t))}})}},{key:"xy",value:function(t,e){var n=this.props,r=n.x,i=n.y,o=n.xy;if(o)return o(this.props,t,e);var s=an[r.base],a=an[i.base];return s&&a?{x:new s(t,this,e).x(r),y:new a(t,this,e).y(i)}:(console.error('anchor[x.base="'.concat(r.base,'",y.base="').concat(i.base,'"] is not supported')),{x:0,y:0})}},{key:"applyWrapText",value:function(t,e,n,r){return function i(o){switch(o){case"left":return{x:n,width:e-n};case"right":return{x:t,width:r-t};case"largest":return i(n-t>=e-r?"left":"right");default:return{x:n,width:r-n}}}(this.props.wrap.wrapText)}},{key:"wrapSquare",value:function(t,e){var n=t.x1,r=t.x2,i=t.y2,o=t.y1,s=void 0===o?i:o,a=this.props,c=a.wrap,u=(c.mode,c.wrapText,a.margin),p=(u=void 0===u?{}:u).right,h=void 0===p?0:p,l=u.left,d=void 0===l?0:l,f=e.bounds(),y=f.left,m=f.top,g=f.right,v=f.bottom;if(i>=m&&i<=v&&!(r<=y||n>=g)&&s!==v)return Object.assign(this.applyWrapText(n,r,y-d,g+h),{y:v})}},{key:"wrapTight",value:function(t,e){var n=this.props.margin,r=n.left,i=void 0===r?0:r,o=n.right,s=void 0===o?0:o,a=t.x1,c=t.x2,u=t.y2,p=e.intersects({x1:a,x2:c,y2:u,y1:u}).sort((function(t,e){return t.x-e.x}));if(p.length>2&&p.splice(1,p.length-1-1),p.length>0)return this.applyWrapText(a,c,p[0].x-i,p.pop().x+s)}},{key:"wrapThrough",value:function(t,e){return this.wrapTight.apply(this,arguments)}},{key:"wrapClear",value:function(t,e){var n=t.x1,r=t.x2,i=t.y2,o=t.y1,s=void 0===o?i:o,a=e.bounds(),c=(a.left,a.top),u=(a.right,a.bottom);if(i>=c&&i<=u&&s!==u)return{x:n,width:r-n,y:u,type:"clear"}}},{key:"wrapTopAndBottom",value:function(){return this.wrapClear.apply(this,arguments)}}]),e}(F(M.dom.Anchor)),Je=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"y_top",value:function(){return 0}},{key:"y_bottom",value:function(){return this.frame.props.height-this.anchor.height}}]),e}(function(){function t(e,n){d()(this,t),this.frame=e,this.anchor=n,this.x0=0,this.y0=0}return y()(t,[{key:"x",value:function(t){var e=t.align,n=t.offset,r=void 0===n?0:n;return e?this["x_".concat(e)]():this.x0+r}},{key:"y",value:function(t){var e=t.align,n=t.offset,r=void 0===n?0:n;return e?this["y_".concat(e)]():this.y0+r}}]),t}()),Ze=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"x",value:function(t){var e=t.align,n=a()(t,["align"]);return new an[e+"Margin"](this.frame,this.anchor).x(n)}},{key:"y",value:function(t){var e=t.align,n=a()(t,["align"]);return new an[e+"Margin"](this.frame,this.anchor).y(n)}}]),e}(Je),$e=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).frame.currentColumn,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x0=i,t.y0=s,t}return k()(e,t),e}(Je),tn=function(t){function e(t,n,r){var i;d()(this,e),i=g()(this,b()(e).apply(this,arguments));var o=new M.ReactQuery(r).findFirstAndParents('[data-content="'.concat(i.anchor.props.id,'"]')),s=o.first,a=o.parents,c=[].concat(a,[s.get(0)]).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0);return i.x0+=c,i}return k()(e,t),e}($e),en=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).frame.props.margin.left,r=void 0===n?0:n;return t.x0=r,t}return k()(e,t),e}(Je),nn=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).frame.props,r=n.margin.right,i=void 0===r?0:r,o=n.width;return t.x0=o-i-t.anchor.width,t}return k()(e,t),y()(e,[{key:"x",value:function(t){var n=t.align,r=t.offset;return n||null==r?x()(b()(e.prototype),"x",this).apply(this,arguments):this.x0-r}}]),e}(Je),rn=function(t){function e(t,n,r){var i;return d()(this,e),(i=g()(this,b()(e).apply(this,arguments))).y0+=i.frame.paragraphY(new M.ReactQuery(r).findFirst('[data-type="paragraph"]').attr("data-content")),i}return k()(e,t),e}($e),on=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).frame.props.margin.top,r=void 0===n?0:n;return t.y0=r,t}return k()(e,t),e}(Je),sn=function(t){function e(){var t;d()(this,e);var n=(t=g()(this,b()(e).apply(this,arguments))).frame.props,r=n.margin.bottom,i=void 0===r?0:r,o=n.height;return t.y0=o-i-t.anchor.height,t}return k()(e,t),y()(e,[{key:"y",value:function(t){var e=t.align,n=t.offset;return e||null==n?this.y.apply(this,arguments):this.y0-n}}]),e}(Je),an={page:Je,margin:Ze,column:$e,character:tn,leftMargin:en,rightMargin:nn,paragraph:rn,line:function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).y0=t.frame.currentY,t}return k()(e,t),e}($e),topMargin:on,bottomMargin:sn},cn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getComposeType",value:function(){return this.props.type||x()(b()(e.prototype),"getComposeType",this).call(this)}},{key:"appendComposed",value:function(t){var n=t.props,r=n.width,i=n.height,o=n.minWidth,s=n.x,c=n.y,u=n.wrap,p=n.anchor,h=n.composedAt,l=n.descent,d=n.pagination,f=n.replaceable;a()(n,["width","height","minWidth","x","y","wrap","anchor","composedAt","descent","pagination","replaceable"]);return x()(b()(e.prototype),"appendComposed",this).call(this,P.a.createElement(yt,{width:r,height:i,minWidth:o,wrap:u,anchor:p,descent:l,pagination:d,x:s,y:c,replaceable:f,composedAt:h,children:P.a.cloneElement(t,{x:void 0,y:void 0,wrap:void 0,anchor:void 0,replaceable:void 0,composedAt:void 0})}))}}]),e}(F(M.dom.Container));function un(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var pn=function t(e){var n,r;return r=n=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"createComposed2Parent",it()((function(){var t=function(){var t=u()(n).props,r=t.I,i=t.width,o=t.height,s=t.margin;return P.a.cloneElement(x()(b()(e.prototype),"createComposed2Parent",u()(n)).call(u()(n)),{key:r,width:i,height:o,margin:s})};return new Proxy(u()(n),{get:function(e,n){return"render"==n?t:e[n]}})}))),n}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){var t=this;return Object.assign(x()(b()(e.prototype),"getChildContext",this).call(this),{isAnchored:function(){return t.isAnchored.apply(t,arguments)},exclusive:function(){return t.exclusive.apply(t,arguments)}})}},{key:"defineProperties",value:function(){x()(b()(e.prototype),"defineProperties",this).call(this),Object.defineProperties(this,{cols:{enumerable:!1,configurable:!0,get:function(){var t=this.props,e=t.width,n=t.height,r=t.margin,i=(r=void 0===r?{}:r).left,o=void 0===i?0:i,s=r.right,a=void 0===s?0:s,c=r.top,u=void 0===c?0:c,p=r.bottom,h=void 0===p?0:p,l=t.cols;return void 0===l?[{x:o,y:u,width:e-o-a,height:n-u-h}]:l}},composedHeight:{enumerable:!1,configurable:!1,get:function(){return Math.max.apply(Math,this.columns.map((function(t){return t.y+(t.height-t.availableHeight)})))}}})}}]),e}(e),h()(n,"displayName",e.displayName.replace("-frame","-"+M.dom.Page.displayName)),h()(n,"factory",t),h()(n,"propTypes",M.dom.Page.propTypes||{}),h()(n,"defaultProps",M.dom.Page.defaultProps||{}),h()(n,"childContextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?un(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):un(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},e.childContextTypes,{isAnchored:E.a.func,exclusive:E.a.func})),r}(Kt),hn=H.enable(F.enable(M.dom,{Document:Mt,Section:Lt,Paragraph:ue,Text:fe,Image:Re,Table:We,Row:Ye,Cell:Qe,Frame:Kt,Shape:Ie,Anchor:Ke,Container:cn,Page:pn}));function ln(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function dn(t){return pt(t,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ln(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ln(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({locatable:!0,navigatable:!0,recomposable:!0},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}))}dn.enable=ut(dn);var fn=n(25),yn=n.n(fn),mn=n(15),gn=n(26),vn=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state,n=e.x,r=void 0===n?0:n,i=e.y,o=void 0===i?0:i,s=e.svg,a=P.a.createElement(yt,{innerRef:function(e){return t.el=e},transform:"translate(".concat(r," ").concat(o,")")},this.props.children);return s?Object(gn.createPortal)(a,s):a}},{key:"componentDidMount",value:function(){var t=this.el,e={svg:t.viewportElement,x:0,y:0};if(0!==this.props.x||0!==this.props.y){var n=t.viewportElement.createSVGPoint();n.x=0,n.y=0,n=n.matrixTransform(t.getCTM()),e.x=n.x,e.y=n.y}this.setState(e)}}],[{key:"getDerivedStateFromProps",value:function(t,e){var n=t.x,r=t.y,i={};return void 0!==n&&(i.x=n),void 0!==r&&(i.y=r),i}}]),e}(C.Component),bn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=a()(t,["children"]);return P.a.createElement(yt,null,e,P.a.createElement(vn,{x:0,y:0},P.a.createElement("rect",lt()({width:"100%",height:"100%",fill:"transparent"},n))))}}]),e}(C.Component),wn=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{moving:!1}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state.moving,n=this.props.children;return P.a.createElement(yt,null,e?P.a.createElement(bn,{cursor:"default",onMouseUp:function(e){return t.onEndMove(e)},onMouseMove:function(e){return t.moving(e)}},P.a.createElement(xn,{ref:function(e){return t.mover=e},cursor:"default"})):null,P.a.cloneElement(n,{onMouseMove:function(e){1&e.buttons&&(e.stopPropagation(),t.setState({moving:!0}))}}))}},{key:"onEndMove",value:function(t){var e=this;if(this.state.moving){var n=this.mover.state,r=n.id,i=n.at;this.setState({moving:!1},(function(){r&&e.props.onMove({dest:{id:r,at:i}})})),t.stopPropagation()}}},{key:"moving",value:function(t){if(this.state.moving){var e=t.clientX,n=t.clientY,r=this.props.around(e,n);r&&this.mover.setState(r)}t.stopPropagation()}}]),e}(C.Component);h()(wn,"propTypes",{onMove:E.a.func.isRequired});var xn=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.state,e=t.x,n=t.y,r=null,i=null;return t.id&&(r=P.a.createElement("rect",{x:e,y:n,width:2,height:20,fill:"black"})),null!=e&&null!=n&&(i=P.a.createElement("rect",{x:e+5,y:n+20,width:10,height:5,fill:"transparent",stroke:"gray",strokeWidth:"1"})),P.a.createElement(vn,{x:0,y:0},i,r)}}]),e}(C.Component);function On(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var kn=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).state={},t.onShrink=t.onShrink.bind(u()(t)),t}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.onMove,n=t.onResize,r=t.onRotate,i=t.shape,o=t.around,s=this.state,a=s.rects,c=void 0===a?[]:a,u=null,p=null;return s.selecting?u=P.a.createElement(Cn,{rects:c,onMouseMove:this.onShrink}):(u=P.a.createElement(Cn,{rects:c}),e&&(u=P.a.createElement(wn,{onMove:e,around:o,children:u}))),i&&(p=P.a.cloneElement(i,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?On(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):On(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({onMove:e,onResize:n,onRotate:r,around:o},i.props))),P.a.createElement(C.Fragment,null,u,p)}},{key:"onShrink",value:function(t){var e=t.buttons,n=t.clientX,r=t.clientY;if(1&e){var i=this.props.asCanvasPoint,o=this.state.rects,s=i({left:n,top:r}),a=s.x,c=s.y,u=o.findIndex((function(t){var e=t.left,n=(t.top,t.right),r=t.bottom;return c<=r&&e<=a&&a<=n})),p=o.slice(0,u+1);-1!=u&&(p[p.length-1].right=a-2),this.setState({rects:p})}}}],[{key:"getDerivedStateFromProps",value:function(t,e){var n=t.rects;return e.selecting?null:{rects:n}}}]),e}(C.Component),Cn=function(t){var e=t.rects,n=a()(t,["rects"]);return P.a.createElement("path",lt()({fill:"#3297FD",style:{fillOpacity:.5},d:e.map((function(t){var e=t.left,n=t.top,r=t.right,i=t.bottom;return"M".concat(e," ").concat(n," L").concat(r," ").concat(n," L").concat(r," ").concat(i," L").concat(e," ").concat(i," Z")})).join(" ")},n,{onClick:function(t){return console.log(1)}}))};function Pn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var jn=Object(mn.compose)(Object(M.connect)((function(t){return{content:t.get("content"),selection:t.get("selection")}}),void 0,void 0,{withRef:!0}))(function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).state={content:null,canvas:null},t}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.range,e=void 0===t?this.props.range:t,n=this.cursor,r=void 0===n?this.props.cursor:n;return P.a.createElement(C.Fragment,null,P.a.createElement("g",{ref:"cursor"},r),e)}},{key:"shouldComponentUpdate",value:function(t,e){var n=t.content,r=t.selection,i=t.positioning,o=t.cursor,s=t.range;if(n.equals(e.content)&&!(n.equals(this.props.content)&&r.equals(this.props.selection)&&n.equals(this.last.content)&&r.equals(this.last.selection))){var c=r.toJS(),u=c.cursorAt,p=a()(c,["cursorAt"]),h=p[u],l=h.id,d=h.at,f=i.position(l,d),y=p.start.id==p.end.id&&p.start.at==p.end.at,m=y?[]:i.getRangeRects(p.start,p.end),g=null,v=i.getComposer(l);if(v&&(g=v.getFocusShape())){var b=g.props,w=b.id,x=b.x,O=void 0===x?0:x,k=b.y,C=void 0===k?0:k,j=p.start.id==p.end.id&&w==l&&p.start.at!=p.end.at,E=!!i.getContent(l).parents("#".concat(w)).length;if(j||E){var S=i.position(w,0)||{},A=S.x,M=void 0===A?0:A,D=S.y,I={x:M+O,y:(void 0===D?0:D)+C,positioning:i};E&&(I.onMove=null),g=P.a.cloneElement(g,I),j&&(m=[])}else g=null}if(this.cursor=o,this.range=s,o&&f){var T=f.x,L=f.y,R=f.left,F=f.top,N=f.height,W=f.fontFamily,z=f.fontSize;this.cursor=P.a.cloneElement(o,{x:T,y:L,left:R,top:F,fontFamily:W,fontSize:z,height:y?N:0})}return s&&(m&&m.length||g)&&(this.range=P.a.cloneElement(s,{rects:m,shape:g})),this.style=f?new En(f,i,p.start,p.end):null,!0}return!1}},{key:"componentDidUpdate",value:function(t){t.selection,t.content;this.scrollCursorIntoView(),this.props.dispatch(M.ACTION.Selection.STYLE(this.style)),this.last={content:this.props.content,selection:this.props.selection}}},{key:"scrollCursorIntoView",value:function(){var t=this.canvas.closest('[style*="overflow"]'),e=this.refs.cursor.getBoundingClientRect(),n=t.getBoundingClientRect(),r=n.top,i=n.height,o=n.bottom,s=void 0===o?r+i:o;e.bottom<r?t.scrollTop-=r-e.top+e.height:e.top>s&&(t.scrollTop+=e.bottom-s+e.height)}},{key:"canvas",get:function(){return this.state.canvas}}]),e}(C.Component)),En=function(){function t(e,n,r,i){d()(this,t),this.position=e,this.positioning=n,this.getComposer=function(t){return n.getComposer(t)},this.getContent=function(t){return n.getContent(t)},this.start=r.id,this.end=i.id,r.id!=i.id&&0==this.getContent(r.id).forwardFirst("#".concat(i.id)).length&&(this.start=i.id,this.end=r.id)}return y()(t,[{key:"toJSON",value:function(){return"Selection.Style"}},{key:"props",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("page"==t.toLowerCase())return this.pageProps();if("layout"==t.toLowerCase())return this.layoutProps();if(e)return this.content(t).props;var n=this.content(t),r=n.id;if(r){var i=this.getComposer(r);if(i)return i.props}}},{key:"layoutProps",value:function(){if(!this.positioning.canvas)return null;var t=this.positioning.pages[this.position.page];return t.layoutOf(t.columnIndexOf(t.lineIndexOf(this.position)))}},{key:"pageProps",value:function(){var t=this;if(!this.positioning.canvas)return null;var e=this.positioning.pages[this.position.page],n=function(){return e.lineIndexOf(t.position)},r=e.props,i=r.margin,o=r.width,s=r.height;return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Pn(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},this.position,{get pageY(){return t.positioning.pageXY(t.position.page).y},get line(){return n()},get column(){return e.columnIndexOf(n())},get cols(){return[].concat(e.cols)},get size(){return{width:o,height:s}},get margin(){return i}})}},{key:"content",value:function(t){if(this.start!=this.end){var e=this.getContent(this.start).forwardUntil("#".concat(this.end));return(e=(e=e.add("#"+this.end).add("#"+this.start,"unshift")).filter(t)).length>0?e.props().toJS():{props:null}}var n=this.getContent(this.position.id),r=n.is(t)?n.props():n.closest(t).props();return r?r.toJS():{props:null}}}]),t}();function Sn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function An(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Sn(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Mn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"position",value:function(t,n){var r=this.getComposer(t);if(!r)return x()(b()(e.prototype),"position",this).apply(this,arguments);var i=r.position(t,n)||{},o=i.page,s=i.x,c=i.y,u=a()(i,["page","x","y"]);if(null!=o){var p=this.pageXY(o),h=p.x,l=p.y;return An({id:t,at:n,x:h+s,y:l+c},this.asViewportPoint({x:h+s,y:l+c}),{page:o},u)}}},{key:"nextLine",value:function(t,e){return this.getComposer(t).nextLine(t,e)||{}}},{key:"prevLine",value:function(t,e){return this.getComposer(t).prevLine(t,e)||{}}},{key:"around",value:function(t,e){var n=this,r=function(){var r,i=n.asCanvasPoint({left:t,top:e}),o=i.x,s=i.y;return{page:n.pages.find((function(t,e){var i=t.props,a=i.width,c=i.height;return r=n.pageXY(e),o>=r.x&&o<=r.x+a&&s>=r.y&&s<=r.y+c})),x:o-r.x,y:s-r.y}}(),i=r.page,o=r.x,s=r.y;return i?i.positionFromPoint(o,s):{}}},{key:"extendSelection",value:function(t,e){if(t.id==e.id)return{start:t,end:e};var n=this.getComposer(t.id).composeFrames(),r=this.getComposer(e.id).composeFrames(),i=n.findLastIndex((function(t,e){return t==r[e]}));return-1!=i&&(n.splice(0,i+1),r.splice(0,i+1)),n[0]&&(t={id:n[0],at:1}),r[0]&&(e={id:r[0],at:1}),{start:t,end:e}}},{key:"getRangeRects",value:function(t,e){var n=this;try{var r=this.extendSelection(t,e);t=r.start,e=r.end;var i=this.getComposer(t.id).closest((function(e){return!!e.getRangeRects&&e.props.id!=t.id})).getRangeRects(t,e,(function(t){return n.pageXY(n.pages.indexOf(t))}));if(1==e.at){var o=this.getComposer(e.id);"paragraph"==o.getComposeType()&&(i[i.length-1].right+=o.enderWidth)}return i}catch(t){return[]}}}]),e}(function(){function t(e){d()(this,t),this.responsible=e}return y()(t,[{key:"getComposer",value:function(){var t;return(t=this.responsible).getComposer.apply(t,arguments)}},{key:"getContent",value:function(){var t;return(t=this.responsible).getContent.apply(t,arguments)}},{key:"position",value:function(t,e){return{page:0}}},{key:"extendWord",value:function(t,e){var n=this.getComposer(t).closest("paragraph");return n?n.extendAtom(t,e):{}}},{key:"around",value:function(t,e){return{}}},{key:"getRangeRects",value:function(t,e){return[]}},{key:"nextLine",value:function(t,e){}},{key:"prevLine",value:function(t,e){}},{key:"getBoundingClientRect",value:function(){return this.canvas.getBoundingClientRect()}},{key:"asCanvasPoint",value:function(t,e){var n=t.left,r=t.top,i=this.canvas.createSVGPoint();i.x=n,i.y=r;var o=i.matrixTransform((e||this.canvas).getScreenCTM().inverse());return{x:o.x,y:o.y}}},{key:"asViewportPoint",value:function(t){var e=t.x,n=t.y,r=this.canvas.createSVGPoint();r.x=e,r.y=n;var i=r.matrixTransform(this.canvas.getScreenCTM());return{left:i.x,top:i.y}}},{key:"pageXY",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.canvas.querySelectorAll(".page"),n=e[t];if(n){var r=n.getBoundingClientRect(),i=r.left,o=r.top;return this.asCanvasPoint({left:i,top:o})}return{x:0,y:0}}},{key:"pageY",value:function(t){return this.pageXY.apply(this,arguments).y}},{key:"canvas",get:function(){return this.responsible.canvas}},{key:"pages",get:function(){return this.responsible.props.pages}},{key:"gap",get:function(){return this.responsible.props.gap}},{key:"scale",get:function(){return this.responsible.props.scale}}]),t}());function Dn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var In=function(t){var e=t.y,n=void 0===e?0:e,r=t.x,i=void 0===r?0:r,o=t.height,s=void 0===o?0:o,a=t.color,c=void 0===a?"black":a,u=t.style;return P.a.createElement("path",{d:"M".concat(i," ").concat(n," v").concat(s),strokeWidth:1,stroke:c,style:u})};In.displayName="CursorShape";var Tn=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"scale",n.props.scale),h()(u()(n),"onMove",n.onMove.bind(u()(n))),h()(u()(n),"onResize",n.onResize.bind(u()(n))),h()(u()(n),"onRotate",n.onRotate.bind(u()(n))),h()(u()(n),"selecting",P.a.createRef()),h()(u()(n),"positioning",new Mn(u()(n))),h()(u()(n),"getComposer",n.getComposer.bind(u()(n))),h()(u()(n),"getContent",n.getContent.bind(u()(n))),n}return k()(e,t),y()(e,[{key:"getComposer",value:function(t){return this.props.getComposer(t)}},{key:"getContent",value:function(t){return M.ContentQuery.fromContent(this.props.content,t?"#".concat(t):void 0)}},{key:"getComposeTrigger",value:function(){var t=this,e=this.props,n=e.continueCompose,r=n.isAllComposed,i=n.isSelectionComposed,o=n.compose4Selection,s=n.compose4Scroll,a=n.composedY,c=(e.pages,e.pgGap,function(e){t.locator?t.locator.setState({content:null,canvas:null},e):e()});return P.a.createElement(Ln,{y:function(){return a()},isSelectionComposed:i,compose4Selection:function(t){r()||c(o)},compose4Scroll:function(t){r()||c((function(){return s(t)}))}})}},{key:"render",value:function(){var t=this,e=this.props,n=e.children,r=e.canvasId,i=(e.continueCompose,e.getComposer),o=e.dispatch,s=(e.viewport,a()(e,["children","canvasId","continueCompose","getComposer","dispatch","viewport"])),c=function(e){var n=e.clientX,r=e.clientY;return n==t.down.clientX&&r==t.down.clientY};return P.a.createElement(Ot,lt()({},s,{innerRef:function(e){t.canvas=e},onContextMenu:function(e){t.onClick(e),t.context.onContextMenu&&t.context.onContextMenu(e)},onClick:function(e){t.down.selected||(t.down.selected=!1,t.onClick(e))},onDoubleClick:function(e){t.down.selected||(t.down.selected=!1,t.onClick(e,!0))},onMouseDown:function(e){var n=e.clientX,r=e.clientY;return t.down={clientX:n,clientY:r}},onMouseMove:function(e){if(1&e.buttons&&!c(e)){var n=t.positioning.around(e.clientX,e.clientY),r=n.id,i=n.at;if(r){var o={id:r,at:i},s=t.selecting.current.state.start,a=void 0===s?o:s,u=a==o?[]:t.positioning.getRangeRects(a,o);t.selecting.current.setState({start:a||o,end:o,rects:u,selecting:!0})}}},onMouseUp:function(e){if(!c(e)){var n=t.selecting.current.state,r=n.start,i=n.end;if(r&&i){t.selecting.current.setState({start:void 0,end:void 0,rects:void 0,selecting:!1});var o=t.positioning.extendSelection(r,i);r=o.start,i=o.end,t.dispatch(M.ACTION.Selection.SELECT(r.id,r.at,i.id,i.at)),t.down.selected=!0}}}}),P.a.createElement(C.Fragment,null,P.a.createElement("defs",null,P.a.createElement("path",{id:"table.adder",width:14,height:20,strokeWidth:1,fill:"transparent",d:"M8,9h8M12,5v8 M12,2C8.13,2,5,5.13,5,9c0,5.25,7,13,7,13s7-7.75,7-13C19,5.13,15.87,2,12,2z"}),P.a.createElement("svg",{id:"rotator",viewBox:"0 0 24 24",width:24,height:24},P.a.createElement("circle",{cx:12,cy:12,r:15,stroke:"transparent",fillOpacity:.01,cursor:"pointer"}),P.a.createElement("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"})))),P.a.createElement(C.Fragment,null,n,this.getComposeTrigger(),P.a.createElement(jn,{canvasId:r,scale:this.props.scale,positioning:this.positioning,ref:"locator",cursor:P.a.createElement(M.Cursor,{dispatch:o,keys:{38:function(e){return t.onKeyArrowUp(e)},40:function(e){return t.onKeyArrowDown(e)}}},P.a.createElement(In,null)),range:P.a.createElement(M.Selection,{around:function(e,n){var r=t.positioning.around(e,n),i=r.id,o=r.at;if(i&&null!==o)return t.positioning.position(i,o)},onMove:this.onMove,onResize:this.onResize,onRotate:this.onRotate},P.a.createElement(kn,{ref:this.selecting,asCanvasPoint:function(e){return t.positioning.asCanvasPoint(e)}})),getComposer:i})))}},{key:"componentDidUpdate",value:function(t,e,n){yn()(t),this.locator&&this.locator.setState({content:this.props.content,canvas:this.canvas})}},{key:"componentDidMount",value:function(){this.active(),this.locator&&this.locator.setState({content:this.props.content,canvas:this.canvas})}},{key:"active",value:function(){this.dispatch(M.ACTION.Cursor.ACTIVE(this.props.canvasId))}},{key:"onRotate",value:function(t){var e=t.degree,n=t.id;n=n||this.selection.start.id;var r=this.getContent(n);this.dispatch(M.ACTION.Entity.UPDATE({id:n,type:r.attr("type"),rotate:e}))}},{key:"onResize",value:function(t){var e=t.x,n=t.y,r=t.id;r=r||this.selection.start.id;var i=this.getContent(r),o=i.attr("width"),s=i.attr("height"),a=null;if(void 0===n)a={width:o+e};else if(void 0===e)a={height:s+n};else{var c=1+Math.max(Math.abs(e)/o,Math.abs(n)/s)*e/Math.abs(e);a={width:o*c,height:s*c}}this.dispatch(M.ACTION.Entity.UPDATE({id:r,type:i.attr("type"),size:a}))}},{key:"onMove",value:function(t){if(t.absolute)this.positioning.asCanvasPoint(t.dest);else this.dispatch(M.ACTION.Selection.MOVE(t))}},{key:"onClick",value:function(t){var e=t.shiftKey,n=(t.target,t.clientX),r=t.clientY,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=this.positioning.around(n,r),s=o.id,a=o.at;if(s)if(null==a)this.dispatch(M.ACTION.Selection.SELECT(s,0,s,1));else if(e){var c=this.selection.end,u=this.positioning.position(s,a),p=u.left,h=u.top,l=this.positioning.position(c.id,c.at),d=l.left,f=l.top;if(h<f||h==f&&p<=d)this.dispatch(M.ACTION.Selection.START_AT(s,a));else{var y=this.positioning.extendSelection(y.end,{id:s,at:a});this.dispatch(M.ACTION.Selection.SELECT(y.start.id,y.start.at,y.end.id,y.end.at))}}else if(i){var m=this.positioning.extendWord(s,a),g=m.start,v=m.end;g&&v?this.dispatch(M.ACTION.Selection.SELECT(g.id,g.at,v.id,v.at)):this.dispatch(M.ACTION.Cursor.AT(s,a))}else this.dispatch(M.ACTION.Cursor.AT(s,a));this.active()}},{key:"onKeyArrow",value:function(t,e,n){if(n){var r=this.selection,i=r.cursorAt,o=a()(r,["cursorAt"]);o[i]={id:t,at:e};var s=this.positioning.extendSelection(o.start,o.end),c=s.start,u=s.end;this.dispatch(M.ACTION.Selection.SELECT(c.id,c.at,u.id,u.at))}else this.dispatch(M.ACTION.Cursor.AT(t,e))}},{key:"locateLine",value:function(t){var e=this.cursor,n=e.id,r=e.at,i=e.x;return this.positioning["".concat(t,"Line")](n,r,i)||{}}},{key:"onKeyArrowUp",value:function(t){var e=t.shiftKey,n=this.locateLine("prev"),r=n.id,i=n.at;r&&this.onKeyArrow(r,i,e)}},{key:"onKeyArrowDown",value:function(t){var e=t.shiftKey,n=this.locateLine("next"),r=n.id,i=n.at;r&&this.onKeyArrow(r,i,e)}},{key:"locator",get:function(){if(this.refs.locator)return this.refs.locator.getWrappedInstance()}},{key:"dispatch",get:function(){return this.props.dispatch}},{key:"selection",get:function(){if(this.locator)return this.locator.props.selection.toJS()}},{key:"cursor",get:function(){var t=this.selection,e=t.cursorAt,n=t.x;return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Dn(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},a()(t,["cursorAt","x"])[e],{x:n})}}]),e}(C.Component);h()(Tn,"contextTypes",{onContextMenu:E.a.func}),h()(Tn,"displayName","composed-document-with-cursor");var Ln=Object(mn.compose)(Object(mn.setDisplayName)("More"),Object(mn.getContext)({debug:E.a.bool}),Object(M.connect)((function(t){return{selection:Object(M.getSelection)(t)}})))(function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"shouldComponentUpdate",value:function(t){var e=t.selection,n=t.isSelectionComposed,r=t.compose4Selection;return!!n(e)||(r(),!1)}},{key:"render",value:function(){var t=this.props,e=t.compose4Scroll,n=t.debug,r=this.props.y();return P.a.createElement(ft.a,{onEnter:function(){return e(r)}},P.a.createElement(yt,{y:r-100},P.a.createElement("line",{x1:"0",y1:"0",x2:"2",y2:"0",strokeWidth:"2",stroke:n?"red":"transparent"})))}}]),e}(C.Component));function Rn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Fn(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Rn(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Nn,Wn,zn=dn(Mt,{continuable:!0}),qn=function(t){function e(t){t.screenBuffer;var n,r=t.viewport;return d()(this,e),(n=g()(this,b()(e).apply(this,arguments))).state=Fn({mode:"content",viewport:r},n.state),n}return k()(e,t),y()(e,[{key:"render",value:function(){return this.state.viewport?x()(b()(e.prototype),"render",this).call(this):P.a.createElement("div",{ref:"viewporter"})}},{key:"renderComposed",value:function(){var t=this,e=this.props,n=(e.canvas,e.scale),r=e.pageGap,i=e.canvasId,o=e.content,s=this.state.viewport,a=this.computed.composed;return P.a.createElement(Tn,{viewport:s,dispatch:this.context.activeDocStore.dispatch,canvasId:i,content:o,getComposer:this.getComposer,scale:n,pgGap:r,pages:a,continueCompose:{isAllComposed:function(){return t.isAllChildrenComposed()},isSelectionComposed:function(e){return t.isSelectionComposed(e)},compose4Selection:function(){return t.setState({mode:"selection",y:0})},compose4Scroll:function(e){return t.setState({mode:"scroll",y:e})},composedY:function(){return t.composedY()}}})}},{key:"componentDidMount",value:function(){this.state.viewport||this.initViewport(this.refs.viewporter),x()(b()(e.prototype),"componentDidMount",this).call(this)}},{key:"componentDidUpdate",value:function(){this.dispatch(M.ACTION.Statistics({pages:this.computed.composed.length,allComposed:this.isAllChildrenComposed(),words:this.composedWords()}))}},{key:"composedWords",value:function(){return Array.from(this.composers.values()).filter((function(t){return!!t})).reduce((function(t,e){return t+(e.computed.atoms?e.computed.atoms.length:0)}),0)}},{key:"shouldContinueCompose",value:function(t){var e=this,n=function(){var t=e.state,n=t.y,r=void 0===n?0:n,i=t.viewport,o=i.height,s=i.node.scrollTop;t.mode;return e.composedY()*e.props.scale<Math.max(s,r)+o+e.bufferHeight}()||!this.isSelectionComposed();return!n&&t&&this.notifyNotAllComposed(t),n}},{key:"composedY",value:function(){var t=this.computed.composed,e=this.props.pageGap;return t.reduce((function(t,n){return t+n.composedHeight+e}),0)}},{key:"isSelectionComposed",value:function(t){var e=t||Object(M.getSelection)(this.context.activeDocStore.getState()),n=e.end,r=e.start;return!r.id||this.composers.has(r.id)&&this.getComposer(r.id).isAllChildrenComposed()&&this.composers.has(n.id)&&this.getComposer(n.id).isAllChildrenComposed()}},{key:"initViewport",value:function(t){for(var e,n=function t(e){var n=window.getComputedStyle(e),r=n.overflowY,i=n.width,o=n.height;return parseInt(i)>0&&parseInt(o)>0?e:"visible"!==r&&"hidden"!==r?e:e?t(e.closest('[style*="overflow"]'))||document.body:null}(t),r=n.getBoundingClientRect().height,i=t;0==(e=i.getBoundingClientRect().width);)i=i.parentNode;this.setState({viewport:{width:parseInt(e),height:parseInt(r||1056),node:n}})}},{key:"getPages",value:function(){return this.computed.composed}},{key:"getRangeRects",value:function(t,e,n){var r=this,i=function(t){return r.getComposer&&r.getComposer(t)||r.context.getComposer&&r.context.getComposer(t)},o=this.getPages(),s=i(t.id);if(t=s.position(t.id,t.at),e=i(e.id).position(e.id,e.at),!t||!e)return[];if(t.id==e.id&&t.page==e.page&&!s.splittable){var a=[t,e].sort((function(t,e){return t.at-e.at})),c=nt()(a,2),u=c[0],p=c[1],h=n(o.find((function(t){return t.props.I==u.page}))),l=h.x,d=h.y;return[{left:l+u.x,top:d+u.y,right:l+p.x,bottom:d+p.y}]}t.page=o.find((function(e){return e.props.I==t.page})),e.page=o.find((function(t){return t.props.I==e.page})),t.line=t.page.lineIndexOf(t),e.line=e.page.lineIndexOf(e);var f=[],y=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0,i=n(t),o=i.x,s=i.y;t.lines.slice(e,r).forEach((function(n,r){var i=t.lineRect(e+r),a=i.left,c=i.top,u=i.width,p=i.height;f.push({left:a+o,top:c+s,right:a+u+o,bottom:c+p+s})}))},m=t.page.props.I>e.page.props.I?[e,t]:t.page.props.I==e.page.props.I&&t.line>e.line?[e,t]:[t,e],g=nt()(m,2),v=g[0],b=g[1];return v.page==b.page?y(v.page,v.line,b.line+1):(y(v.page,v.line),o.slice(v.page.props.I+1,b.page.props.I).forEach((function(t){return y(t)})),y(b.page,0,b.line+1)),f.length&&(Object.assign(f[0],{left:n(v.page).x+v.x}),Object.assign(f[f.length-1],{right:n(b.page).x+b.x})),f}},{key:"nextLine",value:function(t,e){var n=this.query("#".concat(t)).findLast("paragraph").attr("id");if(n)return this.getComposer(n).nextLine(n,1)}},{key:"prevLine",value:function(t,e){var n=this.query("#".concat(t)).findFirst("paragraph").attr("id");if(n)return this.getComposer(n).prevLine(n,1)}},{key:"composeFrames",value:function(){return[this.props.id]}},{key:"bufferHeight",get:function(){return this.props.screenBuffer*this.state.viewport.height}},{key:"viewport",get:function(){return this.state.viewport}}],[{key:"getDerivedStateFromProps",value:function(t,e){var n=t.content;return n&&!n.equals(e.content)?{content:n,mode:"content",y:0}:null}}]),e}(zn);function Bn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(qn,"propTypes",Fn({},zn.propTypes,{pageGap:E.a.number,screenBuffer:E.a.number})),h()(qn,"defaultProps",Fn({},zn.defaultProps,{pageGap:12,screenBuffer:1})),h()(qn,"contextTypes",Fn({},zn.contextTypes,{activeDocStore:E.a.any}));var Yn=dn(Lt,{stoppable:!0}),Hn=V((Wn=Nn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getChildContext",value:function(){var t=x()(b()(e.prototype),"getChildContext",this).call(this);return t.shouldContinueCompose=this.shouldContinueCompose.bind(this),t}},{key:"shouldContinueCompose",value:function(){var t;return!1!==this.computed.allComposed&&(t=this.context.parent).shouldContinueCompose.apply(t,arguments)}},{key:"keepUntilLastAllChildrenComposed",value:function(){var t=this,e=function(e){var n=-1,r=-1;return t.computed.lastComposed.findLast((function(i,o){var s=i.lines;return n=o,s.findLast((function(n,i){if(r=i,e=t.findContentId(n)){var o=t.context.getComposer(e);if(o&&o.isAllChildrenComposed())return!0}return!1}))})),{id:e,pageIndex:n,lineIndex:r}}(),n=e.id,r=e.pageIndex,i=e.lineIndex;return n?(this.keepComposedUntil(r,i+1),C.Children.toArray(this.props.children).findIndex((function(t){return t.props.id===n}))):-1}},{key:"removeChangedPart",value:function(t){var e,n=this,r=-1;return-1!=(e=this.computed.lastComposed.findIndex((function(e){var i=e.lines;return-1!=(r=i.findIndex((function(e){return function(e){var r=n.findContentId(e);return void 0!==r&&t.includes(r)}(e)})))})))&&(this.keepComposedUntil(e,r),!0)}},{key:"keepComposedUntil",value:function(t,e){this.computed.lastComposed=this.computed.lastComposed.slice(0,t+1),this.computed.lastComposed[t].removeFrom(e)}},{key:"appendLastComposed",value:function(){var t=this;this.computed.composed=[].concat(this.computed.lastComposed),this.computed.composed.forEach((function(e){return t.context.parent.appendComposed(e)}))}},{key:"getPages",value:function(){return this.computed.composed}}]),e}(Yn),h()(Nn,"childContextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Bn(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},Yn.childContextTypes,{shouldContinueCompose:E.a.func})),Wn),!0);function _n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Gn(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?_n(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_n(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Qn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){return 0==this.text.length?(this.appendComposed(Gn({},this.defaultStyle,{width:0,minWidth:0,"data-endat":0,children:""})),this.onAllChildrenComposed(),null):x()(b()(e.prototype),"render",this).call(this)}},{key:"position",value:function(t,e){var n=this.measure.defaultStyle,r=n.fontSize,i=n.fontFamily,o=n.height,s=n.descent,a=this.closest("paragraph").props.id,c=this.context.getComposer(a).position(t,e);return Gn({id:t,at:e,fontSize:r,fontFamily:i,height:o,descent:s},c)}}]),e}(dn(fe));function Un(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var Xn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getPages",value:function(){var t=this,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=x()(b()(e.prototype),"getPages",this).call(this);return n?r.reduce((function(e,n,r){return-1!=e.start&&-1!=e.end?e:(new M.ReactQuery(n.render()).findFirst((function(e){var n=e.props,r=n["data-content"],i=n["data-type"];return r==t.props.id||(!t.isSameFrameStack(r,(function(t,e){return t.length==e.length}))||"paragraph"!=i)&&void 0})).length?-1==e.start&&(e.start=r):-1!=e.start&&(e.end=r),e)}),{start:-1,end:-1,extract:function(){return-1==this.start?[]:r.slice(this.start,-1==this.end?void 0:this.end)}}).extract():r}},{key:"lineIndexOf",value:function(t,e){var n=this;return t==this.props.id?0==e?0:this.computed.composed.length-1:this.computed.composed.findIndex((function(r){return r.children.find((function(i,o){var s=new M.ReactQuery(i).findFirst('[data-content="'.concat(t,'"]'));if(s.length>0){var a=s.attr("data-endat");if(null==a)return!0;if(a>e)return!0;if(a==e){if(r.children.length-1!=o)return!0;if(n.context.getComposer(s.attr("data-content")).text.length==a)return!0}}}))}))}},{key:"rectInLine",value:function(t){var e=new M.ReactQuery(t).findFirst('[data-content="'.concat(this.props.id,'"]')).attr("pagination").i-1,n=this.computed.composed[e],r=this.props,i=r.indent,o=i.left,s=void 0===o?0:o,a=i.firstLine,c=void 0===a?0:a,u=r.numbering;return{left:s+(0==e?u?0:c:0),top:0,width:n.currentX,height:n.props.height}}},{key:"xyInLine",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.lineIndexOf(t,e),i=new M.ReactQuery(this.computed.lastComposed[r]).findFirstAndParents(".story"),o=i.first,s=i.parents,a=o.get(0),c=function(){if(t==n.props.id){var r=n.getDefaultMeasure().defaultStyle,i=r.fontSize,o=r.fontFamily,s=r.height,c=r.descent,u={x:0,y:a.props.baseline-(s-c),fontSize:i,fontFamily:o,height:s,descent:c};if(0==e){var p=new M.ReactQuery(a).findFirstAndParents("[data-content]"),h=p.first,l=p.parents;if(1==h.length)u.x=[h.get(0)].concat(l).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0);else{var d=new M.ReactQuery(a).findFirstAndParents(".ender"),f=d.first,y=d.parents;u.x=[f.get(0)].concat(y).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0)}}else if(1==e){var m=new M.ReactQuery(a).findFirstAndParents(".ender"),g=m.first,v=m.parents;u.x=[g.get(0)].concat(v).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0)}return u}return n.xyInStory(t,e,a)}();return s.reduce((function(t,e){var n=e.props,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x+=i,t.y+=s,t}),c)}},{key:"xyInStory",value:function(t,e,n){var r,i=new M.ReactQuery(n).findFirstAndParents((function(n){if(n.props["data-content"]==t&&(null==(r=n.props["data-endat"])||r>=e))return!0})),o=i.first,s=i.parents,a=[o.get(0)].concat(s).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0),c=function(t){var e=t.y,n=void 0===e?0:e,r=t.height,i=void 0===r?0:r,o=t.descent;return n-(i-(void 0===o?0:o))}(o.get(0).props),u=this.context.getComposer(t);if("text"==u.getComposeType()){if(r>=e){var p=o.attr("children"),h=e-(r-p.length);a+=u.measure.stringWidth(p.substring(0,h))}}else if(1==e)return{x:a+o.attr("width")||0,y:c};return{x:a,y:c}}},{key:"isSameFrameStack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t,e){return!0};if(!t)return!0;var n=this.composeFrames(!0),r=this.context.getComposer(t),i=r.composeFrames(!0);return i.reduce((function(t,e,r){return t&&e==n[r]}),e(n,i))}},{key:"getPageLineAndParents",value:function(t,e){var n,r,i=this,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=function(e){var n=e.props,r=n["data-content"],o=n["data-type"],s=n.pagination,a=void 0===s?{}:s;return r==i.props.id&&a.i==t+1||(!i.isSameFrameStack(r,(function(t,e){return t.length==e.length}))||"paragraph"!=o)&&void 0});var s=this.getPages(!1)["find".concat(o?"Last":"")]((function(t){var s=new M.ReactQuery(t.render())["find".concat(o?"Last":"First","AndParents")]((function(n,r){var o=n.props,s=o["data-content"];o["data-type"];return!!i.isSameFrameStack(s)&&e(n,r,t)}));if((r=s.first||s.last).length)return n=s.parents,!0}));return{page:s,line:r,parents:n}}},{key:"getSiblingLine",value:function(t,e,n){var r,i=this,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=this.lineIndexOf(t,e),a=this.xyInLine(t,e,s),c=a.x,u=a.y,p=this.getPageLineAndParents(s,(function(t,e,o){var a=t.props,p=a["data-content"],h=a["data-type"],l=a.pagination,d=void 0===l?{}:l;if(p==i.props.id&&d.i==s+1)return r=new Vn(o,t,[].concat(e),{x:c,y:u}),!1;if(i.isSameFrameStack(p,(function(t,e){return t.length==e.length}))&&"paragraph"==h){if(r){var f=n(r,o,t,e);return null==f||f}return!1}}),o),h=(p.page,p.line),l=p.parents;if(h.length){var d=r.x,f=[].concat(l,[h.get(0)]).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0),y=this.context.getComposer(h.attr("data-content"));return y.positionFromPoint(d-f,void 0,h.attr("pagination").i-1)}}},{key:"flatStory",value:function(t){var e=[],n=[];return new M.ReactQuery(t).find((function(t,r){if(r){var i=e.indexOf(r);-1!=i&&e.splice(i),e.push(r)}if(t.props["data-content"])return n.push({el:t,parents:[].concat(e)}),!1})),n.map((function(t,e){var r=t.el.props.x,i=void 0===r?0:r,o=t.parents;return P.a.cloneElement(n[e].el,{x:o.reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0)+i})}))}},{key:"isSameColumnTableLine",value:function(t,e,n,r){var i=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.findLastIndex((function(e){return e.props["data-type"]==t}));return r[n]==e[n]};if(i("cell"))return!0;if(i("row"))return!1;var o=e.findLast((function(t){return"cell"==t.props["data-type"]}));if(o){var s=r.findLast((function(t){return"cell"==t.props["data-type"]})),a=r.findLast((function(t){return"row"==t.props["data-type"]})),c=function(t,e){return new M.ReactQuery(t).find('[data-type="cell"]').toArray().findIndex((function(t){return t.props["data-content"]==e.props["data-content"]}))};return c(e.findLast((function(t){return"row"==t.props["data-type"]})),o)==c(a,s)}return!0}}]),e}(V(function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"getDefaultMeasure",it()((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.props.defaultStyle;return new n.context.Measure(t)}))),n}return k()(e,t),y()(e,[{key:"createEnder",value:function(){return P.a.createElement(this.constructor.End,lt()({},this.props.defaultStyle,{End:this.props.End,key:"".concat(this.props.id,"-end"),id:"".concat(this.props.id,"-end")}))}},{key:"shouldComponentUpdate",value:function(){return x()(b()(e.prototype),"shouldComponentUpdate",this).apply(this,arguments)&&this.context.shouldContinueCompose(this)}},{key:"getNumberingAtom",value:function(){if(this.context.numbering){var t=this.props,n=t.numbering.style,r=t.indent.firstLine,i=void 0===r?0:r,o=new this.context.Measure(n).defaultStyle;return P.a.createElement(kt,lt()({},o,{className:"numbering",width:-i,children:this.context.numbering(this.props.id)}))}return x()(b()(e.prototype),"getNumberingAtom",this).call(this)}},{key:"clearComposed",value:function(){this.computed.lastText="",this.computed.atoms=[],this.computed.hasFrame=!1,x()(b()(e.prototype),"clearComposed",this).apply(this,arguments)}},{key:"rollbackLines",value:function(t){x()(b()(e.prototype),"rollbackLines",this).call(this,t),this.computed.lastComposed&&this.computed.lastComposed.splice(-t)}},{key:"recalcNumbering",value:function(t){var e=new M.ReactQuery(t),n=e.findFirst(".numbering").get(0),r=this.getNumberingAtom(),i=n.props,o=i.x,s=i.y;return e.replace(n,P.a.cloneElement(r,{x:o,y:s})).root}},{key:"appendLastComposed",value:function(){var t=this,e=this.computed.composed;this.computed.composed=[];var n=this.computed.lastComposed.findIndex((function(n,r){var i=e[r],o=t.context.parent.nextAvailableSpace({height:i.lineHeight()});return i.hasEqualSpace(o)?(t.computed.composed.push(i),0==r&&t.props.numbering&&(n=t.recalcNumbering(n)),t.context.parent.appendComposed(n),!1):(t.computed.lastComposed.splice(r),!0)}));switch(n){case 0:return!1;case-1:return;default:this.commit(this.computed.atoms.indexOf(e[n].first))}}}]),e}(dn(ue,{stoppable:!0})))),Vn=function t(e,n,r,i){var o=i.x,s=i.y;d()(this,t),Object.assign(this,{page:e,line:n,parents:r}),this.isInTable=r.findLast((function(t){return"cell"==t.props["data-type"]})),Object.assign(this,[].concat(r,[n]).reduce((function(t,e){var n=e.props,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x+=i,t.y+=s,t}),{x:o,y:s}))},Kn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"extendAtom",value:function(t,e){var n=this.computed.atoms.find((function(n){return new M.ReactQuery(n).findFirst((function(n){var r=n.props,i=r["data-content"],o=r["data-endat"];return i==t&&(void 0===o?0:o)>=e||void 0})).length>0}));if(n){var r=new M.ReactQuery(n),i=r.findFirst('[data-type="text"]');if(i.length){var o=r.findLast('[data-type="text"]');if(o.length)return{start:{id:i.attr("data-content"),at:parseInt(i.attr("data-endat"))-i.attr("children").length},end:{id:o.attr("data-content"),at:parseInt(o.attr("data-endat"))}}}}return{}}},{key:"position",value:function(t,e){var n=this.lineIndexOf(t,e);if(n>=0){var r=this.getPageLineAndParents(n),i=r.page,o=r.line,s=r.parents;if(i){var a=this.xyInLine(t,e,n);return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Un(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Un(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({page:i.props.I,paragraph:this.props.id,lineIndexOfParagraph:n},[].concat(s,[o.get(0)]).reduce((function(t,e){var n=e.props,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x+=i,t.y+=s,t}),a))}}}},{key:"nextLine",value:function(t,e){var n=this;return this.getSiblingLine(t,e,(function(t,e,r,i){var o=r.props.pagination,s=void 0===o?{}:o;if(t.page.props.I==e.props.I&&t.y>=[].concat(i,[r]).reduce((function(t,e){var n=e.props.y;return t+(void 0===n?0:n)}),0))return!1;if(t.isInTable&&t.line.props.pagination.last)return n.isSameColumnTableLine(r,i,t.line,t.parents);var a,c=i.findLast((function(t){return"cell"==t.props["data-type"]}));if(c&&t.line.props.pagination.last&&1==s.i){var u=c,p=(a=i.indexOf(u),i.slice(0,a+1).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),u.props.width));if(t.x<=p)return!0;var h=i.findLast((function(t){return"row"==t.props["data-type"]}));return new M.ReactQuery(h).find('[data-type="cell"]').toArray().pop().props["data-content"]==u.props["data-content"]}}))}},{key:"prevLine",value:function(t,e){var n=this;return this.getSiblingLine(t,e,(function(t,e,r,i){var o=r.props.pagination,s=void 0===o?{}:o;if(t.page.props.I==e.props.I&&t.y<=[].concat(i,[r]).reduce((function(t,e){var n=e.props.y;return t+(void 0===n?0:n)}),0))return!1;if(t.isInTable&&1==t.line.props.pagination.i&&s.last)return n.isSameColumnTableLine(r,i,t.line,t.parents);var a,c=i.findLast((function(t){return"cell"==t.props["data-type"]}));if(c&&1==t.line.props.pagination.i&&s.last){var u=c,p=(a=i.indexOf(u),i.slice(0,a+1).reduce((function(t,e){var n=e.props.x;return t+(void 0===n?0:n)}),0));if(t.x>=p)return!0;var h=i.findLast((function(t){return"row"==t.props["data-type"]}));return new M.ReactQuery(h).findFirst('[data-type="cell"]').get(0).props["data-content"]==u.props["data-content"]}}),!0)}},{key:"positionFromPoint",value:function(t,e){var n,r,i,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.computed.lastComposed.length-1,c=this.computed.lastComposed[a],u=(n=c.props.children.props,r=n.x,i=void 0===r?0:r,o=n.children,function(t){var e=s.flatStory(o).findLast((function(e){return e.props.x<=t}));if(e){var n=t-e.props.x,r=new M.ReactQuery(e),i=r.findFirst('[data-type="text"]').get(0);if(i){var a=i.props.children,c=s.context.getComposer(i.props["data-content"]).measure.widthString(n,a);return{id:i.props["data-content"],at:i.props["data-endat"]-a.length+c}}return{id:r.findFirst("[data-content]").attr("data-content")}}return{id:s.props.id,at:0}}(t-i));return u}}]),e}(Xn);Kn.propTypes.defaultStyle=E.a.object.isRequired,Kn.contextTypes.numbering=E.a.func;var Jn=Kn,Zn=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.width,n=void 0===e?5:e,r=t.height,i=void 0===r?5:r,o=t.x,s=t.y,a=t.resize,c=t.onStartResize,u={fill:"white",stroke:"lightgray",strokeWidth:1},p={width:n,height:i,style:u,x:o-n/2,y:s-i/2};return a&&(u.cursor="".concat(a.replace("-",""),"-resize"),p.onMouseDown=function(t){return c(a,t)}),P.a.createElement("rect",p)}}]),e}(C.Component);h()(Zn,"propTypes",{x:E.a.number.isRequired,y:E.a.number.isRequired,resize:E.a.string});var $n=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{}),h()(u()(n),"onStartMove",n.onStartMove.bind(u()(n))),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state,n=e.moving,r=e.cursor,i=this.props.children;return n?P.a.createElement(bn,{onMouseUp:function(e){t.setState({moving:void 0}),e.stopPropagation()},onMouseMove:function(e){t.move(e.clientX,e.clientY),e.stopPropagation()},style:{cursor:r}},i):P.a.cloneElement(i,{onMouseDown:this.onStartMove})}},{key:"onStartMove",value:function(t){this.setState({moving:!0})}},{key:"move",value:function(t,e){(0,this.props.onMove)({dest:{left:t,top:e}})}}]),e}(C.Component);h()($n,"propTypes",{onMove:E.a.func.isRequired});var tr=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{}),h()(u()(n),"onStartResize",n.onStartResize.bind(u()(n))),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state,n=e.resizing,r=e.cursor,i=this.props,o=i.children,s=i.onEnd;if(n)return P.a.createElement(bn,{onMouseUp:function(e){t.setState({resizing:void 0}),s&&s(),e.stopPropagation()},onMouseMove:function(e){t.resize(e.clientX,e.clientY),e.stopPropagation()},style:{cursor:r}},o);var a={},c=this.props.direction;return c?a.onMouseMove=function(e){1&e.buttons&&(t.onStartResize(c,e),e.stopPropagation())}:a.onStartResize=this.onStartResize,P.a.createElement(yt,null,P.a.Children.map(o,(function(t){return P.a.cloneElement(t,a)})))}},{key:"onStartResize",value:function(t,e){this.setState({resizing:t,cursor:e.target.style.cursor}),this.left=e.clientX,this.top=e.clientY;var n=this.props.onStart;n&&n()}},{key:"resize",value:function(t,e){var n=this.props.onResize,r=this.state.resizing,i=t-this.left,o=e-this.top;switch(r){case"-ns":o*=-1;case"ns":if(o&&!1===n({y:-o}))return;break;case"-ew":i*=-1;case"ew":if(i&&!1===n({x:i}))return;break;case"-nwse":i*=-1;case"nwse":if(i&&o&&!1===n({x:-i,y:o}))return;break;case"-nesw":i*=-1;case"nesw":if(i&&o&&!1===n({x:i,y:o}))return}this.left=t,this.top=e}}]),e}(C.Component);h()(tr,"propTypes",{onResize:E.a.func.isRequired,direction:E.a.oneOf("ew,ns,nwse,nesw".split(",").reduce((function(t,e){return t.splice(0,0,e,"-"+e),t}),[]))});var er=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{rotating:!1}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.props,n=e.r,r=e.x,i=e.y,o=e.onEnd,s=e.degree,a={width:2*n,height:2*n,style:{fill:"white",stroke:"lightgray",strokeWidth:1},x:r-n,y:i-n};return this.state.rotating?P.a.createElement(bn,{cursor:"crosshair",onMouseUp:function(e){t.setState({rotating:void 0}),o&&o(),e.stopPropagation()},onMouseMove:function(e){t.rotate(e.clientX,e.clientY),e.stopPropagation()}},P.a.createElement("text",{x:r+2*n,y:i},s),P.a.createElement("use",lt()({xlinkHref:"#rotator"},a))):P.a.createElement("use",lt()({xlinkHref:"#rotator"},a,{onMouseDown:function(e){return t.onStartRotate(e)}}))}},{key:"onStartRotate",value:function(t){this.setState({rotating:!0}),this.left=t.clientX,this.top=t.clientY;var e=this.props.onStart;e&&e()}},{key:"rotate",value:function(t,e){!1!==(0,this.props.onRotate)({left:t,top:e,x:t-this.left,y:e-this.top})&&(this.left=t,this.top=e)}}]),e}(C.Component);function nr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function rr(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?nr(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nr(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}h()(er,"propTypes",{x:E.a.number.isRequired,y:E.a.number.isRequired,r:E.a.number,degree:E.a.number});var ir=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.path,n=t.resizeSpots,r=t.onResize,i=t.onMove,o=t.around,s=t.onRotate,a=t.rotate,c=t.positioning,u=t.x,p=t.y,h=t.transform,l=void 0===h?function(t){return t}:h,d=t.id,f=t.absolute,y=f?$n:wn;return P.a.createElement(yt,{x:u,y:p},l(P.a.createElement(C.Fragment,null,P.a.createElement("path",{d:e,fill:"none",stroke:"lightgray"}),i&&P.a.createElement(y,{onMove:function(t){return i(rr({},t,{id:d,absolute:f}))},around:o},P.a.createElement("path",{d:e,fill:"white",fillOpacity:.01,cursor:"move"})),r&&P.a.createElement(tr,{onResize:function(t){return r(rr({},t,{id:d}))}},n.map((function(t,e){return P.a.createElement(Zn,lt()({key:e},t))}))),s&&P.a.createElement(er,lt()({onRotate:function(t){var n=t.left,r=t.top,i=new xe(e).center();i.x+=u,i.y+=p;var o=c.asCanvasPoint({left:n,top:r}),a=parseInt(180*Math.atan2(o.x-i.x,-o.y+i.y)/Math.PI);return a<0&&(a+=360),s({degree:a,id:d})}},a)))))}}]),e}(C.Component);function or(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(ir,"propTypes",{onResize:E.a.func,path:E.a.string,resizeSpots:E.a.arrayOf(E.a.object),onMove:E.a.func,onRotate:E.a.func,rotate:E.a.shape({r:E.a.number,x:E.a.number.isRequired,y:E.a.number.isRequired}),id:E.a.string,absolute:E.a.bool});var sr=dn(Ie),ar=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"composeFrames",value:function(){return[].concat(x()(b()(e.prototype),"composeFrames",this).apply(this,arguments),[this.props.id])}},{key:"getFocusShape",value:function(){var t=this,e=this.geometry.strokeWidth/2,n=e,r=this.props,i=r.width,o=r.height,s=r.rotate,a=void 0===s?0:s,c=r.id,u="M".concat(0," ").concat(0," h").concat(i-0," v").concat(o-0," h").concat(0-i," Z");return P.a.createElement(ir,{id:c,x:e,y:n,path:u,resizeSpots:[{x:0,y:0,resize:"nwse"},{x:(0+i)/2,y:0,resize:"ns"},{x:i,y:0,resize:"nesw"},{x:i,y:(0+o)/2,resize:"ew"},{x:i,y:o,resize:"-nwse"},{x:(0+i)/2,y:o,resize:"-ns"},{x:0,y:o,resize:"-nesw"},{x:0,y:(0+o)/2,resize:"-ew"}],rotate:{r:12,x:(0+i)/2,y:-20,degree:parseInt(a)},transform:function(e){return t.transform(e,new xe(u),1)}})}},{key:"positionFromPoint",value:function(t,e){return{id:this.props.id}}}]),e}(sr);h()(ar,"contextTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?or(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):or(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},sr.contextTypes,{shouldRemoveComposed:E.a.func}));var cr=V(function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).computed.spaces=[],t}return k()(e,t),y()(e,[{key:"nextAvailableSpace",value:function(){var t=x()(b()(e.prototype),"nextAvailableSpace",this).apply(this,arguments),n=t.frame;return-1==this.computed.spaces.indexOf(n)&&this.computed.spaces.push(n),t}},{key:"clearComposed",value:function(){this.computed.spaces=[],x()(b()(e.prototype),"clearComposed",this).apply(this,arguments)}},{key:"appendLastComposed",value:function(){var t=this;if(this.computed.spaces.length>1)return!1;var n=x()(b()(e.prototype),"nextAvailableSpace",this).call(this),r=this.computed.lastComposed.reduce((function(t,e){return t+e.props.height}),0);if(n.height<r)return!1;try{this.computed.lastComposed.forEach((function(e){return t.context.parent.appendComposed(e)})),this.computed.spaces=[n.frame]}catch(t){return console.warn(t),!1}}}]),e}(dn(We))),ur=V(function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"clearComposed",value:function(){this.computed.spaces=[],this.computed.composed=[],x()(b()(e.prototype),"clearComposed",this).call(this)}},{key:"appendLastComposed",value:function(){var t=this;if(this.computed.spaces.length!=this.computed.lastComposed.length)return console.warn("something wrong for this row"),!1;var e=this.context.parent.nextAvailableSpace();if(1==this.computed.spaces.length){var n=this.computed.lastComposed[0];if(e.height>=n.props.height)return this.context.parent.appendComposed(n),void(this.computed.spaces=[e])}else if(this.computed.spaces.length>1&&e.height==this.computed.spaces[0].height)return this.computed.spaces=[],void this.computed.lastComposed.forEach((function(e){t.computed.spaces.push(t.context.parent.nextAvailableSpace({height:e.props.height})),t.context.parent.appendComposed(e)}));return!1}},{key:"injectEmptyCellIntoRank",value:function(t,n,r){this.computed.spaces[0].frame==r&&this.computed.lastComposed.length>0&&(this.computed.lastComposed=[]),x()(b()(e.prototype),"injectEmptyCellIntoRank",this).apply(this,arguments),this.render2Composed.apply(this,arguments)}},{key:"render2Composed",value:function(t,e,n){var r=this,i=t.attr("children");i.forEach((function(t,e){var n,r=new M.ReactQuery(t).findFirstAndParents('[data-type="cell"]'),o=r.first,s=r.parents;i[e]=s.reduceRight((function(t,e){return P.a.cloneElement(e,{},t)}),new(0,(n=o.get(0)).type)(n.props).render())}));var o=e.find((function(t){return"table"==t.props["data-type"]})).props["data-content"],s=!!t.attr("last");i.forEach((function(t,e){var n=new M.ReactQuery(t),i=n.findFirst(".border").attr("children"),a=[].concat(i);i.splice(0,1,P.a.createElement(pr,lt()({key:"edges"},{table:o,row:r.props.id,cell:n.attr("data-content"),i:e,isFirstRowInPage:!1,children:a,height:t.props.height,width:t.props.width,isLastRankOfRow:s})))}));var a,c=new(0,(a=t.get(0)).type)(a.props).render(),u=e.reduceRight((function(t,e){return P.a.cloneElement(e,{},t)}),c);n.currentColumn.children.splice(-1,1,u),this.computed.lastComposed.push(c)}},{key:"shouldContinueCompose",value:function(t){return!0}},{key:"composeFrames",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return t?x()(b()(e.prototype),"composeFrames",this).apply(this,arguments):[].concat(x()(b()(e.prototype),"composeFrames",this).apply(this,arguments),[this.props.id])}}]),e}(dn(Ye,{stoppable:!0,continuable:!0}))),pr=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=nt()(t.children,4),n=e[0],r=e[1],i=e[2],o=e[3],s=t.isFirstRow,a=t.isLastRankOfRow,c=t.table,u=t.row,p=t.cell,h=t.i,l=t.width,d=t.height;t.dispatch;return P.a.createElement(C.Fragment,null,n,s&&P.a.createElement(mr,null),r,a&&P.a.createElement(dr,{x1:0,x2:l,y1:d,y2:d,onResize:function(t,e){var n=t.y;e(M.ACTION.Entity.UPDATE({id:c,type:"table",height:{value:d+n,row:u,cell:p,i:h}}))}})||null,i,0==h&&P.a.createElement(yr,{x1:0,x2:0,y1:0,y2:d,onSelect:function(t){return t(M.ACTION.Selection.SELECT(u))}}),P.a.createElement(lr,{x1:l,y1:0,x2:l,y2:d,onResize:function(t,e){var n=t.x;e(M.ACTION.Entity.UPDATE({id:c,type:"table",width:{value:l+n,row:u,cell:p,i:h}}))}}),o)}}]),e}(C.PureComponent),hr=Object(M.connect)()(function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).state={resizing:!1},t.resize=function(e){return t.props.onResize(e,t.props.dispatch)},t}return k()(e,t),y()(e,[{key:"render",value:function(){var t,e=this,n=this.state.resizing,r=this.props,i=(r.dispatch,r.onResize,r.direction),o=void 0===i?"ew":i,s=r.cursor,c=void 0===s?"col-resize":s,u=a()(r,["dispatch","onResize","direction","cursor"]),p="ew"==o?"y":"x",l=h()({},p,0),d=(t={},h()(t,p+"1","-100%"),h()(t,p+"2","100%"),t);return P.a.createElement(C.Fragment,null,n&&P.a.createElement(vn,l,P.a.createElement("line",lt()({},u,d,{stroke:"lightgray",strokeWidth:1,strokeDasharray:"5,5"}))),P.a.createElement(tr,{direction:o,onStart:function(t){return e.setState({resizing:!0})},onEnd:function(t){return e.setState({resizing:!1})},onResize:this.resize},P.a.createElement("line",lt()({},u,{stroke:"transparent",strokeWidth:5,style:{cursor:c}}))))}}]),e}(C.PureComponent)),lr=function(t){return P.a.createElement(hr,lt()({},t,{direction:"ew",cursor:"col-resize"}))},dr=function(t){return P.a.createElement(hr,lt()({},t,{direction:"-ns",cursor:"row-resize"}))},fr=Object(M.connect)()(function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this.props,e=t.dispatch,n=t.onSelect,r=t.cursor,i=t.size,o=void 0===i?5:i,s=a()(t,["dispatch","onSelect","cursor","size"]);return P.a.createElement("line",lt()({},s,{stroke:"transparent",strokeWidth:o,style:{cursor:r},onClick:function(t){return n(e)}}))}}]),e}(C.PureComponent)),yr=function(t){return P.a.createElement(fr,lt()({},t,{cursor:"e-resize"}))},mr=function(t){return P.a.createElement(fr,lt()({},t,{cursor:"s-resize"}))},gr=(Object(M.connect)()(function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{show:!1}),n}return k()(e,t),y()(e,[{key:"render",value:function(){var t=this,e=this.state.show,n=this.props,r=n.x,i=n.y,o=n.dispatch,s=n.onAdd,a=n.type;return P.a.createElement(yt,{x:r,y:i},P.a.createElement(yt,{x:-12,y:-22},P.a.createElement(yt,{rotate:"".concat("row"==a?"-90 12 22":"")},P.a.createElement("use",{xlinkHref:"#table.adder",stroke:e?"black":"transparent",onMouseOver:function(e){return t.setState({show:!0})},onMouseLeave:function(e){return t.setState({show:!1})},onClick:function(){return s(o)}}))))}}]),e}(C.PureComponent)),function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"clearComposed",value:function(){this.computed.composed=[],x()(b()(e.prototype),"clearComposed",this).call(this)}},{key:"appendLastComposed",value:function(){this.computed.lastComposed=[],this.appendComposed(this.frame)}},{key:"composeFrames",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return t?x()(b()(e.prototype),"composeFrames",this).apply(this,arguments):[].concat(x()(b()(e.prototype),"composeFrames",this).apply(this,arguments),[this.props.id])}}]),e}(dn(Qe)));function vr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var br=function(t){function e(){var t;return d()(this,e),(t=g()(this,b()(e).apply(this,arguments))).splittable=!1,t}return k()(e,t),y()(e,[{key:"getOutline",value:function(){var t=this.props,e=t.outline,n=t.width,r=t.height;return new ar(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?vr(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vr(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({width:n,height:r},e,{margin:{},children:null}),this.context)}},{key:"getFocusShape",value:function(){return P.a.cloneElement(this.getOutline().getFocusShape(),{id:this.props.id})}}]),e}(dn(Re));function wr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var xr=function t(e){return V(function(e){function n(){return d()(this,n),g()(this,b()(n).apply(this,arguments))}return k()(n,e),y()(n,[{key:"clearComposed",value:function(){return this.columns=[],x()(b()(n.prototype),"clearComposed",this).apply(this,arguments)}},{key:"removeChangedPart",value:function(t){var e=this,n=this.lines.findIndex((function(n){return function(n){var r=e.findContentId(n);return void 0!==r&&t.includes(r)}(n)}));return this.rollbackLines(this.lines.slice(n)),!0}},{key:"findLastChildIndexOfLastComposed",value:function(){return this.findContentId(this.lastLine)}},{key:"positionFromPoint",value:function(t,e){var n,r=this,i=new Set,o=[],s=[];if(new M.ReactQuery(this.render()).findFirstAndParents((function(a,c){var u=a.props||{},p=u.width,l=u.height,d=u["data-type"],f=u["data-content"],y=u.className;if((n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?wr(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wr(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({width:p,height:l},r.getBound([].concat(c,[a])))).width&&n.height){if(!function(n){var r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o,a=n.width,c=n.height;return i<=t&&s<=e&&i+a>=t&&s+c>=e}(n))return"line"==y&&function(t){var n=t.y,r=void 0===n?0:n,i=t.height;return r<=e&&r+i>=e}(n)&&o.push({node:a,parents:c,bound:n}),!1;"line"==y&&s.push({node:a,parents:c,bound:n})}if(f){var m=r.context.getComposer(f);if(!m.splittable)return n={id:f},!0;if("text"==d){var g=c.findLast((function(t){return"paragraph"==t.props["data-type"]})),v=g.props.pagination.i,b=t-r.getBound(c.slice(0,c.indexOf(g)+1)).x;return n=m.closest("paragraph").positionFromPoint(b,void 0,v-1),!0}i.add(f)}if(a.type!=yt)return!1})).first.length>0)return{id:n.id,at:n.at};if(o.length||s.length){var a,c=[].concat(o,s).pop(),u=c.bound,p=c.node,l=c.parents,d=[].concat(l,[p]).findLast((function(t){return"paragraph"==t.props["data-type"]})),f=d.props.pagination.i,y=this.context.getComposer(d.props["data-content"]);if(t>=u.x){var m=d.props.width;a=y.positionFromPoint(m,void 0,f-1)}else t<u.x&&(a=y.positionFromPoint(0,void 0,f-1));if(a)return{id:a.id,at:a.at}}return{}}},{key:"lineRect",value:function(t){t=this.lines[t];var e=new M.ReactQuery(t).findFirstAndParents('[data-type="paragraph"]'),n=e.first,r=e.parents,i=[].concat(r,[n.get(0)]).find((function(t){return!!t.props["data-content"]})),o=this.context.getComposer(i.props["data-content"]).rectInLine(t);return o.left=this.columns.find((function(e){return e.children.includes(t)})).x+o.left,o.height=t.props.height,o.top=this.lineY(t)-o.height,o}},{key:"removeFrom",value:function(t){return x()(b()(n.prototype),"rollbackLines",this).call(this,this.lines.length-t,!1)}},{key:"composeFrames",value:function(){return[].concat(x()(b()(n.prototype),"composeFrames",this).apply(this,arguments),[this.props.id])}},{key:"getRangeRects",value:function(t,e,n){var r=this,i=function(t){return r.getComposer&&r.getComposer(t)||r.context.getComposer&&r.context.getComposer(t)},o=this.getPages(),s=i(t.id);if(t=s.position(t.id,t.at),e=i(e.id).position(e.id,e.at),!t||!e)return[];if(t.id==e.id&&t.page==e.page&&!s.splittable){var a=[t,e].sort((function(t,e){return t.at-e.at})),c=nt()(a,2),u=c[0],p=c[1],h=n(o.find((function(t){return t.props.I==u.page}))),l=h.x,d=h.y;return[{left:l+u.x,top:d+u.y,right:l+p.x,bottom:d+p.y}]}t.page=e.page=o.find((function(e){return e.props.I==t.page})),t.line=this.lineIndexOf(t),e.line=this.lineIndexOf(e);var f=[],y=function(t){var e=n(t),i=e.x,o=e.y,s=new M.ReactQuery(t.render()).findFirstAndParents('[data-content="'.concat(r.props.id,'"]')),a=s.first,c=s.parents;return[].concat(c,[a.get(0)]).reduce((function(t,e){var n=e.props,r=n.x,i=void 0===r?0:r,o=n.y,s=void 0===o?0:o;return t.x+=i,t.y+=s,t}),{x:i,y:o})},m=t.page.props.I>e.page.props.I?[e,t]:t.page.props.I==e.page.props.I&&t.line>e.line?[e,t]:[t,e],g=nt()(m,2),v=g[0],b=g[1];return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=y(t),o=i.x,s=i.y;r.lines.slice(e,n).forEach((function(t,n){var i=r.lineRect(e+n),a=i.left,c=i.top,u=i.width,p=i.height;f.push({left:a+o,top:c+s,right:a+u+o,bottom:c+p+s})}))}(v.page,v.line,b.line+1),f.length&&(Object.assign(f[0],{left:n(v.page).x+v.x}),Object.assign(f[f.length-1],{right:n(b.page).x+b.x})),f}}],[{key:"editableLike",value:function(e){return t(e)}}]),n}(dn(e)))}(Kt),Or=V(function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),e}(dn(Ke))),kr=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getPages",value:function(){return[this.createComposed2Parent()]}}]),e}(pn.factory(xr)),Cr=dn.enable(hn,{Document:qn,Section:Hn,Paragraph:Jn,Frame:xr,Shape:ar,Table:cr,Row:ur,Cell:gr,Text:Qn,Image:br,Anchor:Or,Page:kr}),Pr=n(16),jr=n.n(Pr);function Er(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var Sr=new(function(){function t(){d()(this,t),this.families={}}return y()(t,[{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.bold,r=e.italic,i=this.family(t);if(i){if(1==i.length)return i[0];i.sort((function(t,e){return t.bold||0+t.italic||0-e.bold||0-e.italic||0}));var o=i.filter((function(t){return t.bold})),s=i.filter((function(t){return t.italic}));if(n&&r){var a=o.find((function(t){return s.includes(t)}));if(a)return a}return n&&(r||(o=o.filter((function(t){return!s.includes(t)}))),o.length)?o[0]:r&&(n||(s=s.filter((function(t){return!o.includes(t)}))),s.length)?s[0]:i[0]}}},{key:"put",value:function(t,e){if(t.familyName){var n=t.familyName.toLowerCase(),r=this.families[n]=this.families[n]||[];if(!r.find((function(e){return e.fullName==t.fullName}))){var i=t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.assign(t,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Er(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Er(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({lineHeight:function(t){return 1/this.unitsPerEm*t*(this.ascent-this.descent+this.lineGap)},lineDescent:function(t){var e=1/this.unitsPerEm*t;return-this.descent*e},stringWidth:function(t,e){return this.layout(t).advanceWidth/this.unitsPerEm*e}},e))}(t,e),o=i.fullName,s=void 0===o?"":o,a=i.familyName,c=void 0===a?"":a,u=i.subfamilyName,p=void 0===u?"":u,l="".concat(s,",").concat(c,",").concat(p);/bold/i.test(l)&&(t.bold=1),/italic/i.test(l)&&(t.italic=1);t.familyName.toLowerCase();return console.log("font[".concat(t.familyName,"] loaded")),r.push(t),t}}}},{key:"names",value:function(){var t=this;return Object.keys(this.families).map((function(e){return t.families[e][0].familyName})).filter((function(t){return!!t}))}},{key:"family",value:function(t){return this.families[t.toLowerCase()]}}]),t}()),Ar={get:function(){return Sr.get.apply(Sr,arguments)},get names(){return Sr.names().sort()},release:function(){return this.iterateLocal((function(t){return URL.releaseObjectURL(t.src)})),Sr.families={},this},iterateLocal:function(t){Sr.names().forEach((function(e){Sr.family(e).forEach((function(e){e.src&&e.src.startsWith("blob:")&&t(e)}))}))},fromBrowser:function(t){return Promise.all(Array.from(t.files).map((function(t){return new Promise((function(e){var n=URL.createObjectURL(t);Object.assign(new FileReader,{onload:function(t){var r=t.target.result;try{var i=jr.a.create(Buffer.from(r));i?i.fonts?e(Array.from(i.fonts).map((function(t){return Sr.put(t,{src:n})}))):e(Sr.put(i,{src:n})):e()}catch(t){e()}},onerror:function(t){return e()}}).readAsArrayBuffer(t)}))}))).then((function(e){return t.value="",Dr(e)})).finally(Tr)},fromPath:function(t){var e=function(t){return new Promise((function(e){jr.a.open(t,(function(n,r){n?e():r.fonts?e(Array.from(r.fonts).map((function(e){return Sr.put(e,{src:t})}))):e(Sr.put(r,{src:t}))}))}))};return new Promise((function(r,i){t?n(20).readdir(t,(function(n,o){n?i(n):Promise.all(o.map((function(n){return e("".concat(t,"/").concat(n))}))).then((function(t){return r(Dr(t))}),i)})):n(29)().then((function(t){return Promise.all(t.map(e).filter((function(t){return!!t})))})).then((function(t){return r(Dr(t))}),i)}))},fromRemote:function(t){return fetch(t).then((function(t){return t.text()})).then((function(t){var e;try{e=JSON.parse(t)}catch(n){e=t.split(",")}return e.filter((function(t){return!!t})).map((function(t){return t.trim()}))})).then((function(e){return Promise.all(e.map((function(e){var n="".concat(t,"/").concat(e);return fetch(n).then((function(t){if(t.ok)return t.arrayBuffer().then((function(t){return Sr.put(jr.a.create(Buffer.from(t)),{src:n})}))}))})))})).finally(Tr)},load:function(t,e){try{var n=this.get(e);if(void 0!==n)return Promise.resolve(n)}catch(t){}var r={};return("string"==typeof t?fetch(r.src="".concat(t,"/").concat(e)).then((function(t){if(!t.ok)throw new Error(t.statusText);return t.arrayBuffer()})):t(e)).then((function(t){return Sr.put(jr.a.create(Buffer.from(t)),r)})).catch()},asService:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/font-service.js",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("undefined"!=typeof navigator&&"serviceWorker"in navigator){var n,r=Ar.fromBrowser;Ar.fromBrowser=function(){return r.call.apply(r,[Ar].concat(Array.prototype.slice.call(arguments))).finally((function(){return Ar.iterateLocal((function(t){var r=t.familyName,i=t.src;try{n.active.postMessage({familyName:r,src:i,scope:e})}catch(t){console.error(t)}}))}))},navigator.serviceWorker.register("".concat(t),{scope:"".concat(e,"/")}).then((function(e){n=e,e.active&&console.log("Font Service[".concat(t,"] worker active"))})).catch((function(e){console.log("Font Service[".concat(t,"] failed with ")+e)}))}}},Mr=Ar;function Dr(t){return t.reduce((function(t,e){return Array.isArray(e)?t.splice.apply(t,[t.length,0].concat(e)):e&&t.push(e),t}),[])}var Ir=null;function Tr(){Ir||((Ir=document.createElement("style")).id="we_edit_web_fonts",document.body.appendChild(Ir));var t=Array.from(Ir.sheet.rules).map((function(t){return t.style.fontFamily}));Sr.names().filter((function(e){return!t.includes(e)})).forEach((function(t){var e=Sr.get(t),n=e.familyName,r=e.src;r&&n&&Ir.sheet.addRule("@font-face",'font-family:"'.concat(n,'";src: local("').concat(n,'"), url("').concat(r,'");'))}))}var Lr=function(){function t(e){d()(this,t);var n=e.fonts,r=e.size;this.style=e,this.fontFamilys=n.split(",").map((function(t){return t.trim()})).filter((function(t){return!!t})),this.fontFamily=this.fontFamilys[0],this.size=r,this.defaultStyle={whiteSpace:"pre",fontSize:"".concat(r,"pt"),fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",fontFamily:this.fontFamily};var i=this.lineHeight(),o=i.height,s=i.descent;this.defaultStyle.height=this.height=o,this.defaultStyle.descent=this.descent=s}return y()(t,[{key:"lineHeight",value:function(){return{height:25,descent:2}}},{key:"stringWidth",value:function(t){return 200}},{key:"widthString",value:function(t,e){var n=this;return Array.prototype.reduce.call(e,(function(e,r){if(e.done)return e;var i=n.stringWidth(r);return e.width+i>t?(e.done=!0,t-e.width>e.width+i-t&&(e.width+=i,e.text+=r)):(e.width+=i,e.text+=r),e}),{width:0,text:"",done:!1}).text.length}}]),t}(),Rr=null,Fr=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"lineHeight",value:function(){if(!Rr){var t=document.createElement("div");t.style="position:absolute;top:-1000px",document.body.appendChild(t),t.innerHTML='<svg viewBox="0 0 '.concat(100," ",100,'" xmlns="http://www.w3.org/2000/svg"><text>Ä</text></svg>'),(Rr=t.querySelector("text")).setStyle=it()((function(t){return Rr.style=t}))}Rr.setStyle(this.cssStyle()),Rr.firstChild.data="Ä";var e=Rr.getBBox(),n=e.height,r=e.y,i=e.baseline;return{height:n,descent:n-(void 0===i?-r:i)}}},{key:"cssStyle",value:function(){return"white-space:pre;\n font-family:".concat(this.fontFamily,";\n font-size:").concat(this.size,"pt;\n font-weight:").concat(this.style.bold?"700":"400",";\n font-style:").concat(this.style.italic?"italic":"normal",";\n ")}},{key:"stringWidth",value:function(t){return Rr.setStyle(this.cssStyle()),Rr.firstChild.data=t,Rr.getBBox().width}}]),e}(Lr),Nr=n(27),Wr=n.n(Nr),zr=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"getFont",value:function(){return Mr.get(this.fontFamily,this.style)}},{key:"lineHeight",value:function(){return this.font=this.getFont(),{height:96*this.font.lineHeight(this.size)/72,descent:96*this.font.lineDescent(this.size)/72}}},{key:"stringWidth",value:function(t){return 96*this.font.stringWidth(t,this.size)/72}}],[{key:"requireFonts",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=function(){var t=e.filter((function(t){return!Mr.get(t)}));if(t.length>0)return Promise.reject(new Error("font["+t.join(",")+"] can't be loaded!"))};if(e.reduce((function(t,e){return t&&!!Mr.get(e)}),!0))return Promise.resolve(r());if(A.a&&"string"==typeof t&&n(20).existsSync(t))return Mr.fromPath(t).finally(r);switch(Wr()(t)){case"string":return Mr.fromRemote(t).finally(r);case"function":return Promise.all(e.map((function(e){return Mr.load(t,e)}))).finally(r);default:return Promise.resolve(r())}}}]),e}(Lr),qr=n(28),Br=n.n(qr);function Yr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var Hr=/translate\((.*)\s+(.*)\)/,_r=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"output",value:function(t){t.pipe(new Br.a.WritableStream(this,{xmlMode:!0}))}},{key:"onopentag",value:function(t,e){switch(t){case"svg":this.onreset(),this.onDocument(e);break;case"g":"page"==e.class?this.onPage(e):this.onGroup(e);break;case"text":this._currentText=e;break;default:var n="on".concat(t[0].toUpperCase()).concat(t.substr(1));this[n]&&this[n](e)}}},{key:"onclosetag",value:function(t){switch(t){case"g":this.onGroupEnd();break;case"text":this.onText(this._currentText)}}},{key:"onattribute",value:function(t,e){}},{key:"ontext",value:function(t){this._currentText.text=t}},{key:"onprocessinginstruction",value:function(t,e){}},{key:"oncomment",value:function(t){}},{key:"oncommentend",value:function(){}},{key:"oncdatastart",value:function(){}},{key:"oncdataend",value:function(){}},{key:"onerror",value:function(t){}},{key:"onreset",value:function(){this._offsets=[{x:0,y:0}],this._currentText=null,this._asyncJobs=[]}},{key:"onend",value:function(){var t=this;Promise.all(this._asyncJobs).then((function(){t.onDocumentEnd()})).catch((function(e){t.onDocumentEnd(e)}))}},{key:"addAsyncJob",value:function(t){this._asyncJobs.push(t.catch((function(t){return console.error(t),t})))}},{key:"onDocument",value:function(){}},{key:"onDocumentEnd",value:function(){}},{key:"onPage",value:function(t){this.onGroup(t)}},{key:"onImage",value:function(){}},{key:"onText",value:function(t){t.text}},{key:"onGroup",value:function(t){var e=t.transform,n=(void 0===e?"translate(0 0)":e).match(Hr),r=nt()(n,3),i=r[1],o=void 0===i?0:i,s=r[2],a=void 0===s?0:s;this._offsets.push({x:parseInt(o),y:parseInt(a)})}},{key:"onGroupEnd",value:function(){this._offsets.pop()}},{key:"offset",get:function(){return this._offsets.reduce((function(t,e){var n=e.x,r=e.y;return t.x+=n,t.y+=r,t}),{x:0,y:0})}}]),e}(M.Emitter.Format.Base);function Gr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(_r,"defaultProps",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Yr(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yr(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},M.Emitter.Format.Base.defaultProps,{representation:"pagination"}));var Qr=function(t){function e(){return d()(this,e),g()(this,b()(e).apply(this,arguments))}return k()(e,t),y()(e,[{key:"onreset",value:function(){x()(b()(e.prototype),"onreset",this).apply(this,arguments),this.y=0,this.depth=-1,this.defs=new Set}},{key:"spread",value:function(t){return Object.keys(t).map((function(e){return"".concat(e,'="').concat(t[e],'"')})).join(" ")}},{key:"onDocument",value:function(t){var e=t.viewBox,n=this.props.pgGap,r=e.trim().split(/\s+/g),i=nt()(r,4),o=i[2],s=i[3];this.width=n+parseInt(o)+n,this.height=parseInt(s),this.stream.write('<svg\n\tstyle="background:lightgray"\n\twidth="'.concat(this.width,'" height="').concat(this.height,'"\n\txmlns="http://www.w3.org/2000/svg"\n\txmlns:xlink="http://www.w3.org/1999/xlink">\n\t\t')),this.stream.write('<g transform="translate('.concat(n,',0)">'))}},{key:"onDocumentEnd",value:function(t){this.stream.end("</g></svg>")}},{key:"onPage",value:function(t){var e=t.width,n=t.height;e=parseInt(e),n=parseInt(n),this.y+=this.props.pgGap;var r=this.props,i=(r.pgGap,r.pgColor);this.stream.write('<g transform="translate('.concat((this.width-e)/2," ").concat(this.y,')">')),i&&this.stream.write('<rect width="'.concat(e,'" height="').concat(n,'" fill="').concat(i,'"/>')),this.y+=n}},{key:"onImage",value:function(t){var e=this,n=t["xlink:href"];delete t["xlink:href"];var r=btoa(n);if(this.stream.write('<use xlink:href="#'.concat(r,'"/>')),!this.defs.has(n)){this.defs.add(n);var i=fetch(n).then((function(t){if(!t.ok)throw new Error(t.statusText);return t.arrayBuffer()})).then((function(n){var i,o=e.stream;o.write("<defs>"),o.write('<image id="'.concat(r,'" ').concat(e.spread(t)," ")),o.write('xlink:href="data:image/*;base64,'),o.write(btoa((i=new Uint8Array(n)).reduce((function(t,e,n){return t[n]=String.fromCharCode(e),t}),new Array(i.byteLength)).join(""))),o.write('"'),o.write("/>"),o.write("</defs>")}));this.addAsyncJob(i)}}},{key:"onText",value:function(t){var e=t.text,n=a()(t,["text"]);this.stream.write("<text ".concat(this.spread(n),">").concat(e,"</text>"))}},{key:"onGroup",value:function(t){x()(b()(e.prototype),"onGroup",this).apply(this,arguments),this.stream.write("<g ".concat(this.spread(t),">"))}},{key:"onGroupEnd",value:function(){x()(b()(e.prototype),"onGroupEnd",this).call(this),this.stream.write("</g>")}},{key:"onopentag",value:function(){x()(b()(e.prototype),"onopentag",this).apply(this,arguments),this.stream.write("\r\n"),this.depth++,this.stream.write(new Array(this.depth).fill("\t").join(""))}},{key:"onclosetag",value:function(){x()(b()(e.prototype),"onclosetag",this).apply(this,arguments),this.stream.write("\r\n"),this.stream.write(new Array(this.depth).fill("\t").join("")),this.depth--}}]),e}(_r);function Ur(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}h()(Qr,"displayName","SVG"),h()(Qr,"propTypes",function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Gr(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gr(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},_r.propTypes,{pgGap:E.a.number,pgColor:E.a.string})),h()(Qr,"defaultProps",{type:"svg",name:"SVG Document",ext:"svg",representation:"pagination",pgGap:24,pgColor:"white"}),n.d(e,"default",(function(){return Jr})),n.d(e,"Viewers",(function(){return hn})),n.d(e,"Editors",(function(){return Cr})),n.d(e,"FontManager",(function(){return Mr})),n.d(e,"Measure",(function(){return o})),n.d(e,"Composed",(function(){return i})),n.d(e,"composable",(function(){return r})),n.d(e,"editable",(function(){return dn}));var Xr=zr,Vr=Fr,Kr=function(t){return function(e){function n(){return d()(this,n),g()(this,b()(n).apply(this,arguments))}return k()(n,e),y()(n,[{key:"getFont",value:function(){return x()(b()(n.prototype),"getFont",this).call(this)||Mr.get(t)}}]),n}(Xr)},Jr=function(t){function e(){var t,n;d()(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=g()(this,(t=b()(e)).call.apply(t,[this].concat(i))),h()(u()(n),"state",{fontsLoaded:!1}),n}return k()(e,t),y()(e,[{key:"componentDidMount",value:function(){var t=this,e=this.props,n=e.defaultFont,r=e.measure,i=e.fonts;switch(this.Measure=r||(i||A.a?Xr:Vr),this.Measure){case Xr:this.Measure=Kr(n);var o=this.context.doc.getFontList(),s=function(e){var r=Mr.names;r&&r.length&&(Mr.get(n)||(console.warn("default font[".concat(n,"] can't be loaded, set ").concat(r[0]," as default")),t.Measure=Kr(r[0]))),e&&console.error(e.message),t.setState({fontsLoaded:!0})};Xr.requireFonts(i,[n].concat(o)).then(s,s);break;default:this.setState({fontsLoaded:!0})}}},{key:"getChildContext",value:function(){return{Measure:this.Measure}}},{key:"render",value:function(){if(!this.state.fontsLoaded)return P.a.createElement("div",null,"loading fonts...");var t=this.props,e=(t.defaultFont,t.measure,t.fonts,t.type,t.ViewerTypes),n=void 0===e?hn:e,r=t.EditorTypes,i=void 0===r?Cr:r,o=a()(t,["defaultFont","measure","fonts","type","ViewerTypes","EditorTypes"]);return P.a.createElement(M.Representation,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ur(n,!0).forEach((function(e){h()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ur(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({ViewerTypes:n,EditorTypes:i},o,{type:void 0}))}}]),e}(M.Representation.Base);h()(Jr,"displayName","pagination"),h()(Jr,"propTypes",{type:E.a.string.isRequired,measure:E.a.func,fonts:E.a.oneOfType([E.a.string,E.a.func]),defaultFont:E.a.string}),h()(Jr,"defaultProps",{type:"pagination",defaultFont:"Arial"}),h()(Jr,"childContextTypes",{Measure:E.a.func}),h()(Jr,"contextTypes",{doc:E.a.object}),h()(Jr,"Output",_r),function(t){var e=t.install.bind(t);t.install=function(){e.apply(void 0,arguments),Qr.install()};var n=t.uninstall.bind(t);t.uninstall=function(){n.apply(void 0,arguments),Qr.uninstall()}}(Jr),Jr.install()}]);
2//# sourceMappingURL=representation-pagination.js.map
\No newline at end of file