UNPKG

115 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("prop-types")},function(t,e){t.exports=require("@babel/runtime/helpers/defineProperty")},function(t,e){t.exports=require("react")},function(t,e){t.exports=require("@babel/runtime/helpers/classCallCheck")},function(t,e){t.exports=require("@babel/runtime/helpers/getPrototypeOf")},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("@babel/runtime/helpers/objectWithoutProperties")},function(t,e){t.exports=require("@babel/runtime/helpers/assertThisInitialized")},function(t,e){t.exports=require("immutable")},function(t,e){t.exports=require("memoize-one")},function(t,e){t.exports=require("@babel/runtime/helpers/extends")},function(t,e){t.exports=require("@babel/runtime/helpers/typeof")},function(t,e){t.exports=require("recompose")},function(t,e){t.exports=require("redux")},function(t,e){t.exports=require("react-redux")},function(t,e){t.exports=require("readable-stream")},function(t,e){t.exports=require("extend")},function(t,e){Array.prototype.findLast||(Array.prototype.findLast=function(t){var e=this.length;return Array.from(this).reverse().find((function(n,r){for(var i=arguments.length,o=new Array(i>2?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];return t.apply(void 0,[n,e-r-1].concat(o))}))}),Array.prototype.findLastIndex||(Array.prototype.findLastIndex=function(t){return this.indexOf(this.findLast.apply(this,arguments))})},function(t,e){t.exports=require("redux-thunk")},function(t,e){t.exports=require("shortid")},function(t,e){t.exports=require("@babel/runtime/helpers/get")},function(t,e){t.exports=require("react-dom/server.node")},function(t,e){t.exports=require("react-dom")},function(t,e){t.exports=require("@babel/runtime/helpers/construct")},function(t,e){t.exports=require("minimatch")},function(t,e){t.exports=require("react-test-renderer")},function(t,e){t.exports=require("fetch-any")},function(t,e){t.exports=require("react-waypoint")},function(t,e,n){"use strict";n.r(e);n(28),n(19);var r=n(9),i=n.n(r),o=n(12),a=n.n(o),s=n(8),c=n.n(s),u=n(3),l=n.n(u),p=n(7),h=n.n(p),f=n(5),d=n.n(f),y=n(4),g=n.n(y),v=n(6),_=n.n(v),m=n(1),b=n.n(m),w=n(2),O=n.n(w),k=n(0),A=n.n(k),P=n(15),E=n(16),x=n(10),j=n.n(x),C=n(20),T=n.n(C);function S(t){return t.get("undos")}function D(t){return t.get("redos")}function R(t){return t.get("selection").toJS()}function $(t){return t.get("ui").selectionStyle}function I(t){return t.get("statistics")}function q(t){return t.get("doc")}function F(t,e){return t.getIn("content.".concat(e).split("."))}function N(t,e){return t.getIn([e,"parent"])}function L(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"root",r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=[n,t.get(n)],o=i[0],a=i[1];if(!a)return null;var s=a.get("children");return s instanceof x.List?!!s["find".concat(r?"Last":"")]((function(n){var i=t.get(n);console.assert(!!i,"".concat(n," not in content, but parent[").concat(o,"] includes it as child"));var a=e(i);return!0===a||!1!==a&&!!L(t,e,n,r)})):void 0}function M(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"root",r=N(t,n);if(r){var i=t.get(r).get("children"),o=i.indexOf(n);!!i.slice(0,o).findLast((function(n){var r=e(t.get(n));return!0===r||!1!==r&&!!L(t,e,n,!0)}))||M(t,e,r)}}function W(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"root",r=N(t,n);if(r){var i=t.get(r).get("children"),o=i.indexOf(n);!!i.slice(o+1).find((function(n,r){var i=e(t.get(n));return!0===i||!1!==i&&!!L(t,e,n)}))||W(t,e,r)}}function U(t){return function(e,n){switch(n.type){case"we-edit/history/CLEAR":return e.set("redos",[]).set("undos",[]);case"we-edit/history/UNDO":var r=S(e);if(r.length){var i=D(e),o=r.pop(),a=o.selection,s=o.content,c=(o.action,o.patches);return e.get("doc").rollback(c),i.push(o),e.set("content",s).set("selection",a).set("redos",[].concat(i)).set("undos",[].concat(r))}return e;case"we-edit/history/REDO":var u=D(e);if(u.length){var l=u.pop(),p=l.selection,h=l.action,f=S(e);return f.push(l),t(e.set("selection",p),h,{}).set("redos",[].concat(u)).set("undos",[].concat(f))}return e;default:Object.freeze(n);var d={action:n,selection:e.get("selection"),content:e.get("content"),patches:null},y=t(e,n,d);if(y.get("content")!==e.get("content")){var g=S(e);g.push(d);y=(y=y.set("redos",[].concat([]))).set("undos",[].concat(g))}return y}}}var B={ACTIVE:function(t){return{type:"we-edit/selection/CANVAS",payload:t}},AT:function(t,e){return z.SELECT(t,e)},BACKWARD:function(t){return{type:"we-edit/cursor/BACKWARD",payload:t}},FORWARD:function(t){return{type:"we-edit/cursor/FORWARD",payload:t}}},z={SELECT:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e;return{type:"we-edit/selection/SELECTED",payload:{start:{id:t,at:e},end:{id:n,at:r=1==arguments.length?1:r}}}},START_AT:function(t,e){return{type:"we-edit/selection/STARTAT",payload:{id:t,at:e}}},EXTEND:function(t){return{type:"we-edit/selection/EXTEND",payload:t}},COPY:function(t){return{type:"we-edit/selection/COPY",payload:t}},PASTE:function(t){return{type:"we-edit/selection/PASTE",payload:t}},CUT:function(t){return{type:"we-edit/selection/CUT",payload:t}},REMOVE:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:"we-edit/selection/REMOVE",payload:t}},MOVE:function(t){return{type:"we-edit/selection/MOVE",payload:t}},UPDATE:function(t){return{type:"we-edit/selection/UPDATE",payload:t}},STYLE:function(t){return{type:"we-edit/selection/STYLE",payload:t}}},V={Cursor:B,Text:{TYPE:function(t){return{type:"we-edit/text/TYPE",payload:t}},DELETE:function(t){return{type:"we-edit/text/DELETE",payload:t}},BACKSPACE:function(t){return{type:"we-edit/text/BACKSPACE",payload:t}},TAB:function(t){return{type:"we-edit/text/TAB",payload:t}},ENTER:function(t){return{type:"we-edit/text/ENTER",payload:t}},CONTROL:function(t){return{type:"we-edit/text/CONTROL",payload:t}}},Selection:z,Entity:{CREATE:function(t){return{type:"we-edit/entity/CREATE",payload:t}},UPDATE:function(t){return{type:"we-edit/entity/UPDATE",payload:t}}},History:{undo:function(t){var e={type:"we-edit/history/UNDO"};return t&&(e.payload=t),e},redo:function(){return{type:"we-edit/history/REDO"}},clear:function(){return{type:"we-edit/history/CLEAR"}}},Statistics:function(t){return{type:"we-edit/statistics",payload:t}},Refresh:function(){return{type:"we-edit/refresh"}}};function K(t,e){var n=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({serialize:!0}):P.compose;return Object(P.createStore)(t,e,n(Object(P.applyMiddleware)(G,T.a)))}function H(t,e){var n=function(t){var e;return W(t,(function(t){if("paragraph"==t.get("type"))return e=t.get("id"),!0})),e}(e);return t.toJSON=function(){},Object(x.Map)({vendor:"we-edit",doc:t,content:e,selection:j.a.fromJS({start:{id:n,at:0},end:{id:n,at:0},cursorAt:"end"}),ui:{},statistics:{},undos:[],redos:[]})}var G=function(t){return function(t){return function(e){try{return t(e)}catch(t){console.error(t)}}}},J=Object(E.createProvider)("activeDocStore"),Y=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r.storeKey="activeDocStore",Object(E.connect)(t,e,n,r)};function X(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 Q(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?X(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function Z(t,e,n){var r={};if(t.install=function(t,n){var i=t.defaultProps;n&&(i=Q({},i,{},n));var o=i.type;!t.support||t.support()?(t.defaultProps=i,r[o]=t,console.debug("".concat(e,"[").concat(o,"] installed"))):console.log("".concat(e,"[").concat(o,"] discarded because of not supported environment"))},t.uninstall=function(t){var n=t.defaultProps?t.defaultProps.type:t.type;r[n]&&(delete r[n],console.debug("".concat(e,"[").concat(n,"] uninstalled")))},t.get=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=r[t];return n&&!i&&console.error("".concat(e,"[").concat(t,"] not supported")),i},Object.defineProperty(t,"supports",{configurable:!0,get:function(){return Object.freeze(Q({},r))}}),n){var i=new Proxy(r,{get:function(t,e){var r=e[0].toLowerCase()+e.substr(1);if(t[r])return t[r][n];throw new Error},set:function(){throw new Error}});Object.defineProperty(t,n,{configurable:!0,value:i})}return t}var tt=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){var t=this.props,e=t.domain,n=t.EditorTypes,r=t.ViewerTypes,i=t.transformer,o="edit"==e?n:r;return{ModelTypes:o?(void 0===i?function(t){return t}:i)(this.context.transformer(o)):void 0}}},{key:"render",value:function(){var t=this.props,n=t.type,r=t.children,i=c()(t,["type","children"]);if(n){var o=e.get(n);if(o&&o!=this.constructor)return O.a.createElement(o,i,r)}return w.Children.only(this.props.children)}}]),e}(w.PureComponent);b()(tt,"propTypes",{domain:A.a.string,type:A.a.string,EditorTypes:A.a.object,ViewerTypes:A.a.object,transformer:A.a.func}),b()(tt,"defaultProps",{}),b()(tt,"contextTypes",{transformer:A.a.func}),b()(tt,"childContextTypes",{ModelTypes:A.a.object}),b()(tt,"Base",function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,null,[{key:"install",value:function(t){tt.install(this,t)}},{key:"uninstall",value:function(){tt.uninstall(this)}}]),e}(w.Component));var et=Z(tt,"representation","Output"),nt=(n(21),10);var rt=function(){return"".concat(++nt)},it=n(11),ot=n.n(it),at=n(14);function st(){return at.shallowEqual.apply(void 0,arguments)}st.equals=function(t,e){return"equals"in t&&"equals"in e&&t.equals(e)};var ct=st;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 lt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ut(n,!0).forEach((function(e){b()(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}var pt=function(t){function e(){var t;return l()(this,e),(t=d()(this,g()(e).apply(this,arguments))).canvasId="".concat(rt()),t}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){var t=this.props;return{media:t.media,onKeyDown:t.onKeyDown,onContextMenu:t.onContextMenu}}},{key:"render",value:function(){var t=this.props,e=(t.media,t.representation),n=t.scale,r=t.screenBuffer,i=t.children,o=t.viewport,a=c()(t,["media","representation","scale","screenBuffer","children","viewport"]);return"string"==typeof e&&(e=O.a.createElement(et,{type:e})),O.a.cloneElement(e,{domain:this.constructor.domain},this.createDocument({canvasId:this.canvasId,canvasProps:lt({canvas:i,scale:n,screenBuffer:r,viewport:o},a)}))}},{key:"createDocument",value:function(t){return O.a.createElement(yt,t)}}]),e}(w.PureComponent);b()(pt,"displayName","editor"),b()(pt,"domain","edit"),b()(pt,"propTypes",{media:A.a.string,representation:A.a.node.isRequired,scale:A.a.number,screenBuffer:A.a.oneOfType([A.a.func,A.a.number]),viewport:A.a.shape({width:A.a.number,height:A.a.number}),onKeyDown:A.a.func,onContextMenu:A.a.func}),b()(pt,"contextTypes",{events:A.a.object}),b()(pt,"defaultProps",{media:"screen",scale:1}),b()(pt,"childContextTypes",{media:A.a.string,onKeyDown:A.a.func,onContextMenu:A.a.func});var ht=function(t){return t.reduce((function(t,e){return t+e}),0)},ft=ot()((function(t,e){return function n(r){var i=t.get(r),o=i.toJS(),s=o.type,c=o.props,u=o.children,l=e[s[0].toUpperCase()+s.substr(1)];l||(l=e.Unknown,console.warn("[".concat(s,"] not found")));var p=u,h=[i.hashCode()];return Array.isArray(u)&&(p=u.map((function(t){return n(t)}))).every((function(t){return h.push(t.props.hash)})),O.a.createElement(l,a()({key:r,id:r},c,{children:p,hash:ht(h)}))}("root")}),(function(t,e){return t===e||ct.equals(t,e)})),dt=function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"createDocument",ot()((function(t,e,n,r){return O.a.cloneElement(ft(e,r),lt({canvasId:t},n,{canvas:n.canvas||gt,content:e}))}),(function(t,e){return t===e||ct.equals(t,e)||ct(t,e)}))),n}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){return{weDocument:this.getDoc()}}},{key:"shouldComponentUpdate",value:function(t){if(ct(t,this.props))return!1;var e=t.content,n=c()(t,["content"]),r=this.props,i=r.content,o=c()(r,["content"]);return!ct.equals(e,i)||!ct(n,o)}},{key:"getDoc",value:function(){var t=this.context.ModelTypes,e=this.props,n=e.content,r=e.canvasProps,i=e.canvasId;return this.createDocument(i,n,r,t)}},{key:"render",value:function(){return this.context.ModelTypes?this.getDoc():O.a.createElement("div",{style:{color:"red",marginTop:100}},"Representation is not installed")}}]),e}(w.Component);b()(dt,"contextTypes",{ModelTypes:A.a.object}),b()(dt,"childContextTypes",{weDocument:A.a.node});var yt=Y((function(t){return{content:t.get("content")}}))(dt),gt=O.a.createElement((function(t){var e=t.content;return O.a.createElement(w.Fragment,null,e)}),null),vt=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(pt);b()(vt,"displayName","viewer"),b()(vt,"domain","");var _t,mt,bt,wt,Ot=vt,kt=n(13),At=n.n(kt),Pt=n(22),Et=n.n(Pt),xt=n(23),jt=n.n(xt);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}function Tt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ct(n,!0).forEach((function(e){b()(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}var St=function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"groupStreamFormat",ot()((function(t){var r=n.context.activeDocStore.getState().get("content"),i=function(){var t=new Map;return t.set=function(t,e){if(!this.has(t))switch(At()(t)){case"object":break;case"undefined":case"string":Map.prototype.set.call(this,t,[])}return this.get(t)},t},o=[];return w.Children.toArray(t).reduce((function(t,n){return w.Children.toArray(n.props.children).reduce((function(t,n){var r=n.props,i=r.type,o=r.representation;if(n.type==e.Format){var a=e.get(i);t.set(a.defaultProps.representation).push(n)}else t.set(o).push(n);return t}),i()).forEach((function(e,r){t.set(r).push(O.a.cloneElement(n,{children:e}))})),t}),i()).forEach((function(t,e){if(e){var i=n.props,a=(i.media,i.style,i.children,c()(i,["media","style","children"]));o.push(O.a.createElement(et,{type:e,key:e},O.a.createElement(dt,{canvasProps:Tt({canvas:O.a.createElement(Rt,null,w.Children.toArray(t).map((function(t){return O.a.cloneElement(t,a)})))},a),scale:1,content:r})))}else o.push(t)})),o}))),n}return _()(e,t),h()(e,[{key:"render",value:function(){return this.props.representation?Et()(g()(e.prototype),"render",this).call(this):O.a.createElement(w.Fragment,null,this.groupStreamFormat(this.props.children))}}]),e}(Ot);b()(St,"displayName","emitter"),b()(St,"propTypes",Tt({},Ot.propTypes,{input:A.a.object,persist:A.a.func,representation:A.a.node})),b()(St,"defaultProps",Tt({},Ot.defaultProps,{media:"file",domain:"view"})),b()(St,"contextTypes",Tt({},Ot.contextTypes,{activeDocStore:A.a.object})),b()(St,"Format",(mt=_t=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){return{media:St.defaultProps.media}}},{key:"render",value:function(){var t=this.props,e=t.type,n=t.children;if(e){var r=St.get(e,!0);if(r)return O.a.createElement(r,this.props)}return O.a.createElement(w.Fragment,null,n)}}]),e}(w.PureComponent),b()(_t,"displayName","Format"),b()(_t,"childContextTypes",{media:A.a.string}),b()(_t,"Base",(wt=bt=function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"state",{stream:null}),b()(i()(n),"getAllContext",ot()((function(t){var e,r;if(!1 in i()(n))throw new Error("Format.Base implementation has problem because of no global context");var o=Object.keys(t).reduce((function(t,e){return t[e]=A.a.any,t}),{});return r=e=function(e){function n(){return l()(this,n),d()(this,g()(n).apply(this,arguments))}return _()(n,e),h()(n,[{key:"getChildContext",value:function(){return t}},{key:"render",value:function(){return O.a.createElement(w.Fragment,null,this.props.children)}}]),n}(w.Component),b()(e,"childContextTypes",o),r}))),n}return _()(e,t),h()(e,[{key:"render",value:function(){var t=this;if(!this.state.stream)return O.a.cloneElement(this.props.stream,{onReady:function(e){t.setState({stream:e})}});var e=this.emit();return e&&O.a.isValidElement(e)?e:null}},{key:"emit",value:function(){var t=this.getAllContext(this.__reactInternalMemoizedUnmaskedChildContext),e=jt.a.renderToStaticNodeStream(O.a.createElement(t,null,this.props.content));this.output(e)}},{key:"output",value:function(t){throw new Error("Please implement output(content/*a node stream with converted content*/){content.pipe(this.stream)}")}},{key:"stream",get:function(){return this.state.stream}}],[{key:"install",value:function(t){St.install(this,t)}},{key:"uninstall",value:function(){St.uninstall(this)}}]),e}(w.PureComponent),b()(bt,"propTypes",{type:A.a.string.isRequired,name:A.a.string.isRequired,ext:A.a.string.isRequired,representation:A.a.string.isRequired,stream:A.a.node,content:A.a.node}),b()(bt,"contextTypes",{weDocument:A.a.node}),b()(bt,"defaultProps",{}),b()(bt,"Setting",function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"render",value:function(){return null}}]),e}(w.PureComponent)),wt)),mt));var Dt=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"emit",value:function(){var t=this.context.doc.stream();t.pipe(this.stream),t.push(null)}}]),e}(St.Format.Base);b()(Dt,"displayName","[Origin]"),b()(Dt,"propTypes",{}),b()(Dt,"defaultProps",{type:""}),b()(Dt,"contextTypes",{doc:A.a.object});var Rt=function(t){var e=t.children,n=t.content;return O.a.Children.toArray(e).map((function(t){return O.a.cloneElement(t,{content:n})}))};function $t(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?$t(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$t(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}Z(St,"output format"),St.install(St.Format.OutputInput=Dt);var qt=function(t){function e(){var t;return l()(this,e),t=d()(this,g()(e).apply(this,arguments)),b()(i()(t),"getStore",ot()((function(t,e){return t?t.combineReducers?t.combineReducers(e):t:K(Object(P.combineReducers)(It(b()({},Ft,Ut),e)))}),(function(t,e){return t===e||ct(t,e)}))),t.store=t.getStore(t.context.store,t.props.reducers),t}return _()(e,t),h()(e,[{key:"render",value:function(){return O.a.createElement(E.Provider,{store:this.store},this.props.children)}},{key:"componentDidUpdate",value:function(){this.store=this.getStore(this.context.store,this.props.reducers||{})}}]),e}(w.PureComponent);b()(qt,"contextTypes",{store:A.a.object}),b()(qt,"propTypes",{reducers:A.a.object});var Ft="we-edit",Nt={};function Lt(t){var e=t[Ft];return e.docs[e.active]}function Mt(t){var e=t[Ft].docs;return Object.keys(e).map((function(t){return e[t]}))}var Wt=It({ADD:function(t,e){var n=t.id;return Nt[n]=t.buildReducer(e),{type:"".concat(Ft,"/ADD"),payload:{id:n,state:Nt[n](),doc:t}}},CLOSE:function(){return{type:"".concat(Ft,"/CLOSE")}},ACTIVE:function(t){return{type:"".concat(Ft,"/ACTIVE"),payload:t}},MESSAGE:function(t){return{type:"".concat(Ft,"/MESSAGE"),payload:t}}},V);function Ut(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{active:null,docs:{}},e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(n){case"".concat(Ft,"/ADD"):return It({},t,{docs:It({},t.docs,b()({},r.id,r)),active:r.id});case"".concat(Ft,"/ACTIVE"):return It({},t,{active:r});case"".concat(Ft,"/CLOSE"):var i=t.docs[t.active];return i&&(i.doc.release(),delete t.docs[i.id],i=Object.keys(t.docs)[0]),It({},t,{docs:It({},t.docs),active:i});case"".concat(Ft,"/MESSAGE"):return It({},t,{message:r});default:var o=t.active;if(o&&n.startsWith(Ft)){var a=Nt[o],s=(t.docs[o].doc,a(t.docs[o].state,e));if(s)return It({},t,{docs:It({},t.docs,b()({},o,It({},t.docs[o],{state:s})))});var c=It({},t.docs);return delete c[o],It({},t,{docs:c,active:Object.keys(c)[0]})}return t}}function Bt(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?Bt(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Vt=function(t,e){return function(n){var r,i;e=e||function(e){return b()({},t,e)};var o=Object(w.createFactory)(n);return i=r=function(n){function r(){var n;return l()(this,r),(n=d()(this,g()(r).apply(this,arguments))).state={inited:!1},n.context.events&&n.context.events.on(t,n.handler=function(t){n.setState(zt({inited:!0},e(t,n.props)),(function(){return n.forceUpdate()}))}),n}return _()(r,n),h()(r,[{key:"render",value:function(){if(!this.state.inited)return null;var t=this.state,e=(t.inited,c()(t,["inited"]));return o(zt({},this.props,{},e))}},{key:"shouldComponentUpdate",value:function(){return!1}},{key:"componentWillUnmount",value:function(){this.context.events&&this.context.events.removeListener(t,this.handler)}}]),r}(w.Component),b()(r,"displayName","OnlyWhen(".concat(t,")")),b()(r,"contextTypes",{events:A.a.object}),i}},Kt=function(t,e){return function(n){var r,i;e=e||function(e){return b()({},t,e)};var o=Object(w.createFactory)(n);return i=r=function(n){function r(){var n;return l()(this,r),(n=d()(this,g()(r).apply(this,arguments))).state={},n.context.events&&n.context.events.on(t,n.handler=function(t){n.setState(e(t,n.props))}),n}return _()(r,n),h()(r,[{key:"render",value:function(){return o(zt({},this.props,{},this.state))}},{key:"componentWillUnmount",value:function(){this.context.events&&this.context.events.removeListener(t,this.handler)}}]),r}(w.Component),b()(r,"displayName","When(".concat(t,")")),b()(r,"contextTypes",{events:A.a.object}),i}},Ht=("words,composed,emitted,composed.all,emitted.all,cursorPlaced".split(",").reduce((function(t,e){return t[e]=e,t}),{}),n(24));function Gt(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 Jt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Gt(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Yt,Xt,Qt=function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"state",{}),n}return _()(e,t),h()(e,[{key:"componentDidMount",value:function(){var t=this;this.timer=setInterval((function(){document.activeElement!==t.props.input.current?t.setState({visibility:"hidden"}):t.setState({visibility:t.state.visibility?void 0:"hidden"})}),500)}},{key:"render",value:function(){var t=this.props.children,e=this.state.visibility;return O.a.cloneElement(t,{style:Jt({},t.props.style||{},{visibility:e})})}},{key:"componentWillUnmount",value:function(){clearInterval(this.timer)}}]),e}(w.Component),Zt=(n(29),n(18)),te=n.n(Zt);function ee(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 ne=Y((function(t){return{actived:R(t).actived}}))((Xt=Yt=function(t){function e(){var t;l()(this,e),(t=d()(this,g()(e).apply(this,arguments))).state={value:""};var n=t.props.dispatch;return t.KEYs={13:function(t){return n(V.Text.ENTER(t))},46:function(t){return n(V.Text.DELETE(t))},8:function(t){return n(V.Text.BACKSPACE(t))},9:function(t){return n(V.Text.TAB(t))},37:function(t){return n(V.Cursor.BACKWARD(t))},39:function(t){return n(V.Cursor.FORWARD(t))},38:function(t){return n(V.Cursor.BACKWARD(t))},40:function(t){return n(V.Cursor.FORWARD(t))},116:function(t){return n(V.Refresh(t))},c:function(t){return n(V.Selection.COPY(t))},x:function(t){return n(V.Selection.CUT(t))},v:function(t){return n(V.Selection.PASTE(t))},z:function(t){return n(V.History.undo(t))},y:function(t){return n(V.History.redo(t))}},t}return _()(e,t),h()(e,[{key:"render",value:function(){var t,e,n,r,i,o=this,s=this.props,u=s.dispatch,l=s.keys,p=void 0===l?{}:l,h=s.inputRef,f=s.editable,d=c()(s,["dispatch","keys","inputRef","editable"]);return p=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ee(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ee(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},this.KEYs,{},p),0==f&&(delete d.onPaste,delete d.onCut),O.a.createElement("input",a()({ref:h,className:"cursor",type:"text",value:this.state.value},d,(t={onChange:function(t){if(0!=f){var e=t.target.value;!1===t.reactComposition.composition?(u(V.Text.TYPE(e)),o.setState({value:""})):o.setState({value:e})}}},e={},n=te()(!0,{onChange:null},t),r=function(t){return t.target.__REACT_COMPOSITION_SECRET_DATA||{composition:!1}},i=function(t,e){t.target.__REACT_COMPOSITION_SECRET_DATA=te()(!0,t.target.__REACT_COMPOSITION_SECRET_DATA,e)},e.onChange=function(t){t.reactComposition=r(t),n.onChange&&n.onChange(t)},e.onCompositionStart=function(t){n.onCompositionStart&&n.onCompositionStart(t),i(t,{composition:!0})},e.onCompositionUpdate=function(t){n.onCompositionUpdate&&n.onCompositionUpdate(t)},e.onCompositionEnd=function(t){n.onCompositionEnd&&n.onCompositionEnd(t),i(t,{composition:!1}),t.reactComposition=r(t),n.onChange(t)},e),{onKeyDown:function(t){if(0!=f||[37,38,39,40].includes(t.keyCode)){var e=-1!=navigator.userAgent.indexOf("Mac OS"),n=t.key,r=t.keyCode,i=t.ctrlKey,a=t.metaKey,s=p[r]||(e&&a||i)&&p[n];if(s)return t.preventDefault(),void s(re(t));o.context.onKeyDown&&!1!==o.context.onKeyDown(t)&&u(V.Text.CONTROL(re(t)))}else t.preventDefault()}}))}},{key:"componentDidUpdate",value:function(){this.props.inputRef.current.focus()}}]),e}(w.Component),b()(Yt,"contextTypes",{onKeyDown:A.a.func}),Xt)),re=function(t){return Object.keys(t).reduce((function(e,n){return n.endsWith("Key")&&(e[n]=t[n]),e}),{keyCode:t.keyCode})};function ie(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 oe(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ie(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ie(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var ae=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"render",value:function(){var t=this.props,e=t.top,n=t.left,r=t.height,i=t.color,o=t.fontFamily,s=t.fontSize,u=c()(t,["top","left","height","color","fontFamily","fontSize"]),l={height:r,margin:0,padding:0,border:0,left:10,top:10,position:"fixed",outline:"none"};return O.a.createElement("div",{unselectable:"on",style:{left:n,top:e,position:"fixed",height:0,width:0}},O.a.createElement(ne,a()({style:oe({},l,{color:i,fontSize:s,fontFamily:o,width:2,background:"transparent"})},u)))}}]),e}(w.PureComponent),se=function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"input",O.a.createRef()),n}return _()(e,t),h()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=(t.editable,c()(t,["children","editable"]));return O.a.createElement(w.Fragment,null,Object(Ht.createPortal)(O.a.createElement(ae,a()({},n,{inputRef:this.input,height:e?1:n.height})),document.body),e&&O.a.createElement(Qt,{input:this.input},O.a.cloneElement(e,n)))}}]),e}(w.Component);b()(se,"propTypes",{editable:A.a.bool});var ce,ue,le=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=c()(t,["children"]);return O.a.cloneElement(e,n)}}]),e}(w.PureComponent),pe=n(17);function he(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 fe(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?he(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):he(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var de=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"shouldComponentUpdate",value:function(){return!1}},{key:"render",value:function(){var t=this.props,n=t.type,r=t.children,i=t.onFinish,o=c()(t,["type","children","onFinish"]),a=(o.path,o.name,c()(o,["path","name"])),s=this.constructor.get(n)||e.Base,u=[],l=O.a.createElement(w.Fragment,null,w.Children.toArray(r).map((function(t,e){var r,i;return u.push(new Promise((function(t){r=t,i=t}))),O.a.cloneElement(t,fe({key:e},a,{stream:O.a.createElement(s,fe({},o,{format:t.props.type,onFinish:function(e){r({type:n,format:fe({},t.props),stream:e})},onError:function(e,r){i({type:n,format:fe({},t.props),stream:e,error:r})}}))}))})));return Promise.all(u).then(i,i),l}}]),e}(w.Component);b()(de,"propTypes",{type:A.a.string,onFinish:A.a.func}),b()(de,"defaultProps",{onFinish:function(t){return t}}),b()(de,"Base",(ue=ce=function(t){function e(){var t;return l()(this,e),((t=d()(this,g()(e).apply(this,arguments))).context.inRender||t.props.now||"undefined"==typeof document)&&(t.render=function(){return null},t.componentDidMount=function(){t.doCreate()}),t}return _()(e,t),h()(e,null,[{key:"install",value:function(t){de.install(this,t)}},{key:"uninstall",value:function(){de.uninstall(this)}}]),h()(e,[{key:"render",value:function(){return null}},{key:"doCreate",value:function(){var t=this;return Promise.resolve(this.create()).then((function(e){var n=t.props,r=n.onFinish,i=n.onError,o=n.onReady;return e.on("finish",(function(){return r(e)})),e.on("error",(function(t){return i(e,t)})),o(e),e}))}},{key:"create",value:function(){var t=this.props.write,e=void 0===t?function(t,e,n){console.debug(t.toString()),process.nextTick(n)}:t;return new pe.Writable({write:e,autoDestroy:!0})}}]),e}(w.Component),b()(ce,"propTypes",{onFinish:A.a.func,onError:A.a.func,write:A.a.func}),b()(ce,"contextTypes",{inRender:A.a.bool}),ue)),b()(de,"Collection",(function(t){var e=t.children,n=c()(t,["children"]);return O.a.createElement(w.Fragment,null,w.Children.toArray(e).map((function(t,e){return O.a.cloneElement(t,fe({},n,{},t.props))})))})),Z(de,"output stream");var ye=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"render",value:function(){return O.a.createElement(w.Fragment,null,this.props.children||null)}},{key:"getComposeType",value:function(){return this.constructor.getType()}}],[{key:"getType",value:function(){return this.displayName.split("-").pop()}}]),e}(w.Component);b()(ye,"displayName","unknown");var ge=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"render",value:function(){return null}}]),e}(ye);b()(ge,"displayName","ignore");var ve=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(ve,"displayName","container");var _e=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(_e,"displayName","document"),b()(_e,"propTypes",{canvas:A.a.node,canvasId:A.a.string,scale:A.a.number,screenBuffer:A.a.oneOfType([A.a.func,A.a.number]),viewport:A.a.shape({width:A.a.number,height:A.a.number}),content:A.a.object});var me=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(me,"displayName","section"),b()(me,"propTypes",{create:A.a.func,page:A.a.shape({width:A.a.number,height:A.a.number,margin:A.a.shape({left:A.a.number,right:A.a.number,top:A.a.number,bottom:A.a.number}),cols:A.a.oneOfType([A.a.arrayOf(A.a.shape({x:A.a.number,y:A.a.number,width:A.a.number})),A.a.shape({num:A.a.number,space:A.a.number,y:A.a.number})])})});var be=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(be,"displayName","paragraph"),b()(be,"propTypes",{spacing:A.a.shape({lineHeight:A.a.oneOfType([A.a.string,A.a.number]),top:A.a.number,bottom:A.a.number}).isRequired,indent:A.a.shape({left:A.a.number,right:A.a.number,firstLine:A.a.number}).isRequired,align:A.a.string,numbering:A.a.shape({style:A.a.shape({fonts:A.a.string.isRequired,size:A.a.number.isRequired,bold:A.a.bool,italic:A.a.bool}).isRequired,label:A.a.string.isRequired}),defaultStyle:A.a.shape({fonts:A.a.string.isRequired,size:A.a.number.isRequired,bold:A.a.bool,italic:A.a.bool}),widow:A.a.bool,orphan:A.a.bool,keepLines:A.a.bool,keepWithNext:A.a.bool,End:A.a.string}),b()(be,"defaultProps",{spacing:{},indent:{},widow:!0,orphan:!0,End:String.fromCharCode(182)}),b()(be,"contextTypes",{isAnchored:A.a.func,exclusive:A.a.func});var we=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(we,"displayName","text"),b()(we,"propTypes",{fonts:A.a.string.isRequired,size:A.a.number.isRequired,color:A.a.string,bold:A.a.bool,italic:A.a.bool,vanish:A.a.bool,highlight:A.a.string,border:A.a.object,underline:A.a.string,strike:A.a.bool});var Oe=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(Oe,"displayName","image"),b()(Oe,"propTypes",{width:A.a.number.isRequired,height:A.a.number.isRequired,src:A.a.string}),b()(Oe,"defaultProps",{width:1,height:1});var ke=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(ke,"displayName","table"),b()(ke,"propTypes",{width:A.a.number.isRequired,headers:A.a.number,indent:A.a.number}),b()(ke,"defaultProps",{headers:0,indent:0});var Ae=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(Ae,"displayName","row"),b()(Ae,"propTypes",{height:A.a.number,headers:A.a.number,footers:A.a.number,keepLines:A.a.bool,cols:A.a.arrayOf(A.a.shape({x:A.a.number,width:A.a.number})).isRequired}),b()(Ae,"defaultProps",{headers:0,footers:0});var Pe={sz:A.a.number,color:A.a.string},Ee={sz:1,color:"black"},xe=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(xe,"displayName","cell"),b()(xe,"propTypes",{border:A.a.shape({left:A.a.shape(Pe),right:A.a.shape(Pe),top:A.a.shape(Pe),bottom:A.a.shape(Pe)}),margin:A.a.shape({left:A.a.number,right:A.a.number,top:A.a.number,bottom:A.a.number}),background:A.a.string,vertAlign:A.a.oneOf(["top","middle","center","bottom"])}),b()(xe,"defaultProps",{border:{left:Ee,right:Ee,top:Ee,bottom:Ee},margin:{left:0,right:0,top:0,bottom:0},background:"transparent"});var je=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(je,"displayName","frame"),b()(je,"propTypes",{width:A.a.number.isRequired,height:A.a.number,named:A.a.string,cols:A.a.arrayOf(A.a.shape({x:A.a.number,width:A.a.number.isRequired})),vertAlign:A.a.oneOf(["top","middle","center","bottom"])});var Ce=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(Ce,"displayName","anchor"),b()(Ce,"propTypes",{x:A.a.shape({base:A.a.string,offset:A.a.number,align:A.a.string}).isRequired,y:A.a.shape({base:A.a.string,offset:A.a.number,align:A.a.string}).isRequired,margin:A.a.shape({left:A.a.number,right:A.a.number,top:A.a.number,bottom:A.a.number}),wrap:A.a.shape({mode:A.a.oneOf("TopAndBottom,Square,Tight,Through".split(",")),wrapText:A.a.oneOf("bothSides,left,right,largest".split(","))}).isRequired});var Te=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(Te,"displayName","shape"),b()(Te,"propTypes",{position:A.a.shape({x:A.a.number,y:A.a.number}),width:A.a.number,height:A.a.number,margin:A.a.shape({left:A.a.number,right:A.a.number,top:A.a.number,bottom:A.a.number}),geometry:A.a.string,outline:A.a.shape({width:A.a.number.isRequired,solidFill:A.a.string}),solidFill:A.a.string,blipFill:A.a.shape({url:A.a.string}),rotate:A.a.number,scale:A.a.number}),b()(Te,"defaultProps",{margin:{left:0,right:0,top:0,bottom:0}});var Se=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),e}(ye);b()(Se,"displayName","page"),b()(Se,"propTypes",{width:A.a.number.isRequired,height:A.a.number.isRequired,margin:A.a.shape({top:A.a.number,left:A.a.number,right:A.a.number,bottom:A.a.number})}),b()(Se,"defaultProps",{margin:{top:0,left:0,right:0,bottom:0}});var De={Unknown:ye,Ignore:ge,Container:ve,Document:_e,Section:me,Paragraph:be,Text:we,Image:Oe,Table:ke,Row:Ae,Cell:xe,Frame:je,Shape:Te,Anchor:Ce,Page:Se};function Re(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 $e(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Re(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Re(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Ie=function(t,e){var n=e.type,r=e.payload;switch(n){case"we-edit/selection/SELECTED":return $e({},t,{cursorAt:"end"},r);case"we-edit/selection/CANVAS":return $e({},t,{active:r,actived:Date.now()});case"we-edit/selection/STARTAT":return $e({},t,{cursorAt:"start",start:r});default:return t}};function qe(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 Fe(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?qe(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qe(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Ne=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{words:0,pages:0},e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(n){case"we-edit/statistics":return Fe({},t,{},r);default:return t}};function Le(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?Le(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Le(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var We=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{selectionStyle:null},e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(n){case"we-edit/selection/STYLE":return Me({},t,{selectionStyle:r});default:return t}},Ue=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){return{doc:this.props.doc,transformer:this.props.transformer}}},{key:"render",value:function(){var t=this.props,e=t.children;t.readonly,t.doc;return O.a.createElement(w.Fragment,null,e)}},{key:"componentWillUnmount",value:function(){var t=this.props.onQuit;t&&t()}}]),e}(w.Component);b()(Ue,"propTypes",{doc:A.a.object,transformer:A.a.func.isRequired,onQuit:A.a.func}),b()(Ue,"childContextTypes",{doc:A.a.object,transformer:A.a.func});var Be=function(t,e,n){return function(r,i,o){switch(i.type){case"we-edit/refresh":return r.setIn(["content","root","props","key"],Date.now())}var a,s=r.get("content").asMutable(),c=r.set("_content",s),u=t(s);e.renderChanged=function(t){return e.renderNode(t,u,n)};try{if("function"==typeof e.startTransaction&&e.startTransaction(),"function"==typeof e.onChange){var l=e.onChange(c,i);if(!1===l)return r;if((a=l)instanceof x.Map&&"we-edit"==a.get("vendor"))r=l.remove("_content");else if("object"==At()(l)){var p=l.selection;p&&(r=r.mergeIn(["selection"],p)),r=r.setIn(["content"],s.asImmutable())}else r=r.mergeIn(["selection"],Ie(R(r),i));"function"==typeof e.commit&&(o.patches=e.commit())}}catch(t){console.error(t),"function"==typeof e.rollback&&e.rollback()}finally{return r}}},ze=function(t){return function(e){return function(n,r,i,o){console.assert(!!n);var a=o.id||t.makeId(o),s={type:n.displayName,id:a,props:r,children:Array.isArray(i)?i.map((function(t){return t.id})):i};return e.hasIn([a,"parent"])&&(s.parent=e.getIn([a,"parent"])),e.set(a,j.a.fromJS(s)),Array.isArray(i)&&i.forEach((function(t){return e.mergeIn([t.id],{parent:a})})),{id:a,type:n,props:r,children:i}}}},Ve=function t(e,n,r){var i=this;l()(this,t),this.key=n,this.getState=function(){try{return r?r(e.getState()):e.getState()[n]}catch(t){return{}}},this.dispatch=function(t){return"function"==typeof t?t(i.dispatch,i.getState):e.dispatch(t)},this.subscribe=e.subscribe.bind(e),this.replaceReducer=e.replaceReducer.bind(e)},Ke=n(25),He=n.n(Ke);function Ge(t,e,n){try{return function(r){return!!t.split(",").map((function(t){return function(t,e,n){var r=t.split(/(?=[><+~\s])/g),i=r.slice(1).map((function(t){return Ye[t[0]]})),o=Qe((r=r.map((function(t){return t.replace(/^[><+~]/,"")})).map((function(t){return t.trim()}))).pop(),n),a=r.map((function(t,r){var o=Qe(t,n);return function(t){return e(t)[i[r]](o).length>0}})).reverse();return function(t){if(o(t)&&!a.find((function(e){return!e(t)})))return!0}}(t.trim(),e,n)})).find((function(t){return t(r)}))||void 0}}catch(t){throw t}}function Je(t){return"string"==typeof t&&"#"==(t=t.trim())[0]&&!Xe.test(t)}var Ye={">":"parent","<":"children"," ":"parents","+":"prev","~":"next"},Xe=/[\s\[,:<>+~]/;function Qe(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=t.split(/(?=[#\.\[\]])/g).map((function(t){return"]"==t[0]?t.substr(1):t})).filter((function(t){return!!t})).map((function(t){switch(t[0]){case"#":return e["#"](t.substr(1));case"[":var n=t.substr(1).split("=");return 2==n.length&&(n[1]=n[1].replace(/^['"]/,"").replace(/['"]$/,"")),e["["].apply(e,n);case".":return e["."](t.substr(1));case"*":if("*"==t)return function(t){return!!t};default:return e.type(t)}}));return function(t){return!n.find((function(e){return!e(t)}))}}var Ze=function(t){return t instanceof x.Map},tn=function(){function t(e,n){var r=this;return l()(this,t),this.state=e,this._content=this._getContent(),this._nodes=[],this._$=function(t){return new r.constructor(e,t)},n?n instanceof t?n:(Ze(n)&&(n=[n]),Array.isArray(n)?(n.forEach((function(t){Ze(t)?r._nodes.push(t.get("id")):"string"==typeof t&&r._nodes.push(t)})),this):"string"==typeof n&&"root"!=n?(this._nodes.push("root"),this.find(n)):void 0):(this._nodes.push("root"),this)}return h()(t,null,[{key:"fromContent",value:function(e,n){return new t({get:function(t){return e}},n)}}]),h()(t,[{key:"_getContent",value:function(){return this.state.get("content")}},{key:"props",value:function(){return this.length?this._content.get(this._nodes[0]):null}},{key:"attr",value:function(t){if(this.length){var e=[this._nodes[0]];return["type","id","parent","children"].includes(t)?e.push(t):(e.push("props"),e=e.concat(t.split("."))),this._content.getIn(e)}return null}},{key:"parent",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);return i&&i.has("parent")&&n(i=e._content.get(i.get("parent")))&&t.add(i.get("id")),t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"parents",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){for(var i=e._content.get(r);i&&i.has("parent")&&(i=e._content.get(i.get("parent")));)n(i)&&t.add(i.get("id"));return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"parentsUntil",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},n=en(e,this._$),r=this._nodes.reduce((function(e,r){for(var i=t._content.get(r);i&&i.has("parent")&&(i=t._content.get(i.get("parent")))&&!n(i);)e.add(i.get("id"));return e}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"closest",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){for(var i=e._content.get(r);i;){if(n(i)){t.add(i.get("id"));break}if(!i.has("parent"))break;r=i.get("parent"),i=e._content.get(r)}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"next",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o){var a=o.indexOf(r);a<o.size-1&&(++a,n(e._content.get(o.get(a)))&&t.add(o.get(a)))}}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"nextAll",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o)for(var a=o.indexOf(r)+1;a<o.size;a++)n(e._content.get(o.get(a)))&&t.add(o.get(a))}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"nextUntil",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o)for(var a=o.indexOf(r)+1;a<o.size&&!n(e._content.get(o.get(a)));a++)t.add(o.get(a))}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"forwardFirst",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){return W(e._content,(function(e){var r=n(e);return r?(t.add(e.get("id")),!0):!1!==r&&void 0}),r),t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"forwardUntil",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},n=en(e,this._$),r=this._nodes.reduce((function(e,r){return W(t._content,(function(t){var r=n(t);return!!r||(e.add(t.get("id")),!1!==r&&void 0)}),r),e}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"prev",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o){var a=o.indexOf(r);a>0&&(--a,n(e._content.get(o.get(a)))&&t.add(o.get(a)))}}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"prevAll",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o)for(var a=0,s=o.indexOf(r);a<s;a++)n(e._content.get(o.get(a)))&&t.add(o.get(a))}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"prevUntil",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.get(r);if(i&&i.has("parent")){var o=e._content.getIn([i.get("parent"),"children"]);if(o)for(var a=0,s=o.indexOf(r);a<s&&!n(e._content.get(o.get(a)));a++)t.add(o.get(a))}return t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"backwardFirst",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){return M(e._content,(function(e){var r=n(e);return r?(t.add(e.get("id")),!0):!1!==r&&void 0}),r),t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"backwardUntil",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},n=en(e,this._$),r=this._nodes.reduce((function(e,r){return M(t._content,(function(t){var r=n(t);return!!r||(e.add(t.get("id")),!1!==r&&void 0)}),r),e}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"to",value:function(t){var e=this,n=this._$(t),r=[this.attr("id")];return this.forwardUntil((function(t){return!!n.is(t)||(0==e._$(t).findFirst(n).length?(r.push(t.get("id")),!1):void 0)})).length>0?(r.push(n.attr("id")),this._$(Array.from(new Set(r)))):this._$([])}},{key:"children",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.reduce((function(t,r){var i=e._content.getIn([r,"children"]);return i&&i instanceof x.List&&i.forEach((function(r){n(e._content.get(r))&&t.push(r)})),t}),[]);return new this.constructor(this.state,r)}},{key:"find",value:function(t){var e=this;if(Je(t))return this.findFirst(t);var n=en(t,this._$),r=this._nodes.reduce((function(t,r){return L(e._content,(function(e){n(e)&&(console.assert(!!e),t.add(e.get("id")))}),r),t}),new Set);return new this.constructor(this.state,Array.from(r))}},{key:"findFirst",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Je(t)&&this._nodes.includes("root")){var i=t.substr(1);return new this.constructor(this.state,this._content.has(i)?[i]:[])}var o=en(t,this._$),a=this._nodes.reduce((function(t,i){return t.length>0?t:n&&o(e._content.get(i))?(t.push(i),t):(L(e._content,(function(e){if(o(e))return t.push(e.get("id")),!0}),i,r),t)}),[]);return new this.constructor(this.state,a)}},{key:"findLast",value:function(t,e){return this.find(t,e,!0).last()}},{key:"filter",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.filter((function(t){return n(e._content.get(t))}));return new this.constructor(this.state,r)}},{key:"slice",value:function(t,e){return new this.constructor(this.state,this._nodes.slice(t,e))}},{key:"not",value:function(t){var e=this,n=en(t,this._$),r=this._nodes.filter((function(t){return!n(e._content.get(t))}));return new this.constructor(this.state,r)}},{key:"first",value:function(){return new this.constructor(this.state,this._nodes.slice(0,1))}},{key:"last",value:function(){return new this.constructor(this.state,this._nodes.slice(-1))}},{key:"eq",value:function(t){return new this.constructor(this.state,this._nodes.slice(t,t+1))}},{key:"get",value:function(t){return this._content.get(this._nodes[t])}},{key:"has",value:function(t){var e=this,n=en(t,this._$);return-1!=this._nodes.findIndex((function(t){return n(e._content.get(t))}))}},{key:"is",value:function(t){var e=this,n=en(t,this._$);return-1==this._nodes.findIndex((function(t){return!n(e._content.get(t))}))}},{key:"each",value:function(t,e){var n=this;return this._nodes.forEach((function(r,i){var o=n._content.get(r);t.bind(e||o)(i,o,n._$)})),this}},{key:"map",value:function(t,e){var n=this,r=this._nodes.map((function(r,i){var o=n._content.get(r);return t.bind(e||o)(i,o,n._$)})).filter((function(t){return!!t}));return 0==r.length||r.find((function(t){return!Ze(t)}))?r:new this.constructor(this.state,r)}},{key:"add",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"push",n=[].concat(this._nodes);return new this.constructor(this.state,t)._nodes.forEach((function(t){n.includes(t)||n[e](t)})),new this.constructor(this.state,n)}},{key:"text",value:function(){var t=this;return this._nodes.map((function(e){var n=t._content.get(e);return"text"==n.get("type")?n.get("children"):new t.constructor(t.state,[e]).find("text").map((function(t,e){return e.get("children")})).join("")})).join("")}},{key:"indexOf",value:function(t){return this._nodes.indexOf(this._$(t)._nodes[0])}},{key:"toArray",value:function(){return[].concat(this._nodes)}},{key:"toJS",value:function(){var t=this._getContent();return this._nodes.length>0?function e(n){if(t.has(n)){var r=t.get(n).toJS(),i=(r.id,r.parent,r.children),o=c()(r,["id","parent","children"]);return Array.isArray(i)?o.children=i.map((function(t){return e(t)})).filter((function(t){return!!t})):o.children=i,o}return null}(this._nodes[0]):{}}},{key:"toString",value:function(){return JSON.stringify(this.map((function(t,e,n){return n(e).toJS()})),null,4)}},{key:"length",get:function(){return this._nodes.length}}]),t}();function en(t,e){switch(At()(t)){case"function":return t;case"object":if(t instanceof tn)return function(e){return t.has(e)};if(t instanceof x.Map)return function(e){return e.get("id")==t.get("id")};throw new Error("not supported object selector");case"string":return Ge(t,e,{"#":function(t){return function(e){return e.get("id")==t}},"[":function(t,e){return function(n){return!!n.hasIn(["props",t])&&(void 0===e||(e=e.replace(/^['"]/).replace(/$['"]/),n.getIn(["props",t])==e))}},".":function(t){return function(e){return!!e.hasIn(["props","className"])&&e.getIn(["props","className"]).split(/\s+/).includes(t)}},type:function(t){return function(e){return e.get("type")==t}}});default:return function(t){return!0}}}var nn=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"_getContent",value:function(){return this.state.get("_content")}},{key:"remove",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=function n(r){if(e){var i=t._content.getIn([r,"children"]);i instanceof x.List&&i.forEach((function(t){return n(t)})),t._content.remove(r)}else t._content.remove(r)};return this._nodes.forEach((function(e){var r=t._content.getIn([e,"parent"]),i=t._content.getIn([r,"children"]);if(i instanceof x.List){var o=i.indexOf(e);-1!=o&&t._content.removeIn([r,"children",o])}n(e)})),this}},{key:"before",value:function(t){var e=this,n=this.parent().attr("id"),r=new this.constructor(this.state,t).attr("id"),i=this.attr("id");return this._content.updateIn([n,"children"],(function(t){return t.splice(t.indexOf(i),0,r)})),this._content.updateIn([r,"parent"],(function(t){return t&&e._content.has(t)&&e._content.updateIn([t,"children"],(function(t){return t.splice(t.indexOf(r),1)})),n})),this}},{key:"after",value:function(t){var e=this,n=this.parent().attr("id"),r=new this.constructor(this.state,t).attr("id"),i=this.attr("id");return this._content.updateIn([n,"children"],(function(t){return t.splice(t.indexOf(i)+1,0,r)})),this._content.updateIn([r,"parent"],(function(t){return t&&e._content.has(t)&&e._content.updateIn([t,"children"],(function(t){return t.splice(t.indexOf(r),1)})),n})),this}},{key:"prepend",value:function(t){var e=this,n=new this.constructor(this.state,t).attr("id");this._content.updateIn([this.attr("id"),"children"],(function(t){return t.splice(0,0,n)})),this._content.updateIn([n,"parent"],(function(t){return t&&e._content.has(t)&&e._content.updateIn([t,"children"],(function(t){return t.splice(t.indexOf(n),1)})),e.attr("id")}))}},{key:"append",value:function(t){var e=this,n=new this.constructor(this.state,t).attr("id");this._content.updateIn([this.attr("id"),"children"],(function(t){return t.splice(t.length-1,0,n)})),this._content.updateIn([n,"parent"],(function(t){return t&&e._content.has(t)&&e._content.updateIn([t,"children"],(function(t){return t.splice(t.indexOf(n),1)})),e.attr("id")}))}}]),e}(tn);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 on(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?rn(n,!0).forEach((function(e){b()(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 an=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"isEmpty",value:function(){var t=this.$target;return 0==t.findFirst(this.cursorable).length&&(t.is("paragraph")||!this.cursorable(t.get(0)))}},{key:"isWhole",value:function(){var t=this.selection,e=t.start,n=t.end;return e.id==n.id&&0==e.at&&0!=n.at&&("text"==this.$target.attr("type")?n.at>=this.$target.text().length:n.at>=1)}},{key:"emit",value:function(t,e){for(var n=this,r=e.find((function(e){return"".concat(t,"_").concat(e)in n})),i=arguments.length,o=new Array(i>2?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];if(r)return this.debug&&console.debug({message:"".concat(t,"_").concat(r),action:t,conds:e,payload:o}),this["".concat(t,"_").concat(r)].apply(this,o.concat([e]));this.debug&&console.warn({message:"event without handler",action:t,conds:e,payload:o})}},{key:"clean",value:function(t){var e=this,n=this.$target.forwardFirst(this.cursorable),r=this.$target.backwardFirst(this.cursorable);if(0!=n.length||0!=r.length){var i=this.$target.closest("paragraph");t&&t(),i.find("text").filter((function(t){return 0==e.$(t).text().length})).each((function(t,n){var r=e.$(n).parentsUntil(i).not(i),o=(r.toArray().findIndex((function(t){return e.$("#"+t).length>1}))+1||r.length)-1,a=r.eq(o).attr("id")||n.get("id");e.$("#".concat(a)).remove(),e.file.getNode(a).remove()})),0==this.$target.length&&(n.closest(i).length>0?this.cursorAt(n.attr("id"),0):r.closest(i).length>0?this.cursorAtEnd(r.attr("id")):this.cursorAtEnd(i.attr("id")))}}},{key:"type",value:function(){this.remove(),this.emit.apply(this,["type",this.conds].concat(Array.prototype.slice.call(arguments)))}},{key:"enter",value:function(){this.remove(),this.emit.apply(this,["enter",this.conds].concat(Array.prototype.slice.call(arguments)))}},{key:"tab",value:function(){this.remove(),this.emit.apply(this,["tab",this.conds].concat(Array.prototype.slice.call(arguments)))}},{key:"forward",value:function(){this.emit.apply(this,["forward",this.conds].concat(Array.prototype.slice.call(arguments)))}},{key:"backward",value:function(){this.emit.apply(this,["backward",this.conds].concat(Array.prototype.slice.call(arguments)))}},{key:"copy",value:function(){var t=this,e=this.selection,n=e.start,r=e.end;if(n.id!=r.id||n.at!=r.at)if(n.id==r.id)this.clipboard=this.emit("serialize",this.conds);else{var i=this.$target.to("#"+r.id).toArray();this.cursorAt(n.id,n.at,n.id,this.cursorAtEnd(n.id).end.at);var o=this.emit("serialize",this.conds),a=i.slice(1,i.length-1).map((function(e){return t.selectWhole(e),t.emit("serialize",t.conds)}));this.cursorAt(r.id,0,r.id,r.at);var s=this.emit("serialize",this.conds);this.clipboard=[o].concat(a,[s]).join(""),this.cursorAt(n.id,n.at,r.id,r.at)}}},{key:"cut",value:function(){var t=this,e=this.selection,n=e.start,r=e.end;n.id==r.id&&n.at==r.at||(n.id==r.id?this.clipboard=this.emit("serialize",this.conds):(this.seperateSelection(),this.clipboard=this.$target.to("#"+r.id).toArray().map((function(e){return t.selectWhole(e),t.emit("serialize",t.conds)})).join("")),this.remove())}},{key:"paste",value:function(){var t=this;this.remove(),this.file.attach(this.clipboard).each((function(e,n){var r=t.file.renderChanged(n).id,i=t.$("#".concat(r));t.emit("paste_"+i.attr("type"),t.conds,i,n)}))}},{key:"conds",get:function(){var t=this,e=this.content.get(this.selection.start.id),n=e.toJS(),r=n.type,i=n.children,o=n.parent,a=this.content.getIn([o,"type"]),s=this.selection.start,c=(s.id,s.at),u=void 0===c?0:c,l=(this.isWhole()?"whole":this.isEmpty()&&"empty")||0==u&&"beginning_of"||("text"==r?u>=i.length&&"end_of":1==u&&"end_of")||"",p=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];switch(l){case"whole":e=t.content.get(e.get("parent"));case"empty":for(;n=t.content.get(e.get("parent"));){var i=n.get("children");if(1!=i.size||i.first()!=e.get("id"))break;r.unshift(n.get("type")),e=n}break;case"beginning_of":for(;(n=t.content.get(e.get("parent")))&&n.get("children").first()===e.get("id");)r.unshift(n.get("type")),e=n;break;case"end_of":for(;(n=t.content.get(e.get("parent")))&&n.get("children").last()===e.get("id");)r.unshift(n.get("type")),e=n}return r}(e),h=p.map((function(t){return"up_to_".concat(t)}));return a&&(h=[].concat(h.map((function(t){return"".concat(t,"_in_").concat(a)})),h,["in_".concat(a)])),h=h.map((function(t){return"".concat(l,"_").concat(r,"_").concat(t)})),h=[].concat(h,p.map((function(t){return"".concat(l,"_up_to_").concat(t)}))),[].concat(h,["".concat(l,"_").concat(r),r,l.replace(/_of$/,"")]).filter((function(t){return!!t})).map((function(t){return t.replace(/^_/g,"")})).map((function(t){return"at_"+t}))}}]),e}(function(){function t(e,n){l()(this,t),this._state=e,this._undoables={},this._selection=R(e),this._file=q(e),this._content=e.get("_content"),this.$=function(t){return new nn(e,t)},this.cursorable=this.cursorable.bind(this)}return h()(t,[{key:"state",value:function(){var t={};return Object.keys(this._undoables).length>0&&(t.undoables=this._undoables),Object.keys(this._selection).length>0&&(t.selection=this._selection),t}},{key:"cursorAt",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,i=arguments.length>4?arguments[4]:void 0,o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return"start"!=i&&"end"!=i||(this._selection.cursorAt=i),this._selection=on({},this._selection,{start:{id:t,at:e},end:{id:n,at:r}}),o&&this.fixSelection(),this._selection}},{key:"cursorAtEnd",value:function(t){return"text"==this.content.getIn([t,"type"])?this.cursorAt(t,this.content.getIn([t,"children"]).length):this.cursorAt(t,1)}},{key:"selectWhole",value:function(t){return"text"==this.content.getIn([t,"type"])?this.cursorAt(t,0,t,this.content.getIn([t,"children"]).length):this.cursorAt(t,0,t,1)}},{key:"cursorable",value:function(t){var e=t.get("type"),n=t.get("children");switch(e){case"text":return(n||"").length>0;case"image":return!0;case"paragraph":return 0==this.$(t).findFirst(this.cursorable).length||void 0;default:return!n||void 0}}},{key:"fixSelection",value:function(){var t=this.fixSelection;this.fixSelection=function(t){return t};try{var e=this.selection,n=e.start,r=e.end;if(n.id!=r.id&&n.at!=r.at){if(0==r.at){var i=this.$("#".concat(r.id)).backwardFirst(this.cursorable);i.length>0&&this.cursorAtEnd(i.attr("id")),r=this.selection.end}if(this.cursorAtEnd(n.id),n.at==this.selection.start.at){var o=this.$("#".concat(n.id)).forwardFirst(this.cursorable);o.length>0&&(n.id=o.attr("id"),n.at=0)}for(var a=null;(a=this.$("#".concat(n.id))).find("#".concat(r.id)).length>0;)this.cursorAt(a.children().first().attr("id"),0,r.id,r.at),n=this.selection.start;for(;(a=this.$("#".concat(r.id))).find("#".concat(n.id)).length>0;)this.cursorAtEnd(a.children().last().attr("id")),r=this.selection.end;if(n.id!=r.id&&0==this.$("#".concat(n.id)).forwardFirst("#".concat(r.id)).length){var s={start:r,end:n};n=s.start,r=s.end,this.selection.cursorAt="start"==this.selection.cursorAt?"end":"start"}this.cursorAt(n.id,n.at,r.id,r.at)}else if(n.id==r.id&&n.at==r.at&&0==this.$target.closest("paragraph").length){var c=this.$target.findFirst("paragraph");1==c.length&&this.cursorAt(c.attr("id"),0)}}finally{this.fixSelection=t}}},{key:"safeCursor",value:function(t){var e=this,n=this.$target,r=n.parents().toArray(),i=[n.attr("id")].concat(r).reduce((function(t,n,r,i){if(r<i.length-1){var o=e.content.getIn(i[r+1],"children");t.push(o.indexOf(n))}return t}),[]);t&&t();var o=r.findIndex((function(t){return e.content.has(t)})),a=i[o],s=this.$("#".concat(r[o])),c=s.children();c.length>a?this.cursorAt(c.eq(a).attr("id"),0):c.length>0?this.cursorAtEnd(c.last().attr("id")):this.cursorAtEnd(s.attr("id"))}},{key:"init",value:function(){var t=this.$().findFirst("paragraph");t.length>0&&(this.cursorAt(t.attr("id"),0),this.forward(),this.backward())}},{key:"type",value:function(t){}},{key:"delete",value:function(t){}},{key:"backspace",value:function(t){}},{key:"enter",value:function(t){}},{key:"tab",value:function(t){}},{key:"create",value:function(t){t.type}},{key:"update",value:function(t){t.id,t.type,c()(t,["id","type"])}},{key:"remove",value:function(){}},{key:"copy",value:function(){}},{key:"cut",value:function(){}},{key:"paste",value:function(){}},{key:"backward",value:function(){}},{key:"forward",value:function(){}},{key:"extend",value:function(t){var e=this.$target.closest(t);e.length>0&&this.selectWhole(e.attr("id"))}},{key:"clipboard",get:function(){return window._clipboard},set:function(t){return window._clipboard=t}},{key:"selection",get:function(){return this._selection}},{key:"file",get:function(){return this._file}},{key:"content",get:function(){return this._content}},{key:"$target",get:function(){return this.$("#".concat(this.selection.start.id))}},{key:"target",get:function(){return this.file.getNode(this.selection.start.id)}}]),t}()),sn={seperateSelection:function(){var t=this.selection,e=t.start,n=t.end;if(e.id==n.id){if(e.at==n.at)return;if("text"!=this.content.getIn([e.id,"type"]))return;if(0==e.at&&n.at>=this.content.getIn([e.id,"children"]).length-1)return}this.cursorAt(n.id,n.at);var r=this.conds;r.includes("at_end")||this.emit("seperate",r.map((function(t){return t+"_for_end"}))),n=this.selection.start,this.cursorAt(e.id,e.at,n.id,n.at),(r=this.conds).includes("at_whole")||r.includes("at_beginning")||this.emit("seperate",this.conds.map((function(t){return t+"_for_start"})))},seperate_at_text_for_end:function(){var t=this.selection.start,e=t.id,n=t.at,r=this.target,i=r.text();r.text(i.substring(0,n));r.clone().text(i.substring(n)).insertAfter(r);this.file.renderChanged(this.file.getNode(this.$target.parent().attr("id"))),this.cursorAtEnd(e)},seperate_at_text_for_start:function(){var t=this.selection,e=t.start,n=e.id,r=e.at,i=t.end,o=this.target,a=o.text();o.text(a.substring(0,r));var s=o.clone().text(a.substring(r)).insertAfter(o),c=this.file.makeId(s);this.file.renderChanged(this.file.getNode(this.$target.parent().attr("id"))),i.id==n&&(i.id=c,i.at=a.length-r),this.cursorAt(c,0,i.id,i.at)},seperate_at_beginning_for_end:function(){var t=this.$target.backwardFirst(this.cursorable).attr("id");t&&this.cursorAtEnd(t)},seperate_at_empty_for_end:function(){this.cursorAtEnd(this.selection.start.id)},seperate_at_empty_for_start:function(){var t=this.selection,e=t.start,n=t.end;this.cursorAt(e.id,0,n.id,n.at)},seperate_at_end_for_start:function(){var t=this.selection.end,e=this.$target.forwardFirst().attr("id");e&&this.cursorAt(e,0,t.id,t.at)},seperate_up_to_paragraph_at_beginning:function(){var t=this,e=this.InlineContainers,n=this.target.attr("_creating",1),r=n.closest(this.PARAGRAPH_),i=r.clone(),o=i.find("[".concat("_creating","=1]"));o.parents(e).each((function(e,n){t.file.$(n).nextAll(":not(".concat(t.PR,")")).remove()})),o.nextAll().add(o).remove(),r.before(i),n.parents(e).each((function(e,n){t.file.$(n).prevAll(":not(".concat(t.PR,")")).remove()})),n.prevAll().remove(),this.target.removeAttr("_creating");var a=this.file.renderChanged(i),s=this.$target.closest("paragraph");s.before("#"+a.id),this.file.renderChanged(r),this.cursorAt(s.attr("id"),0)}},cn={create:function(t){var e=t.type;return this.remove(),this.emit.apply(this,["create",[].concat(this.conds,[""]).map((function(t){return e.toLowerCase()+(t&&"_")+t}))].concat(Array.prototype.slice.call(arguments))),this},create_table_at_text:function(){this.seperate_at_text_for_end(),this.create.apply(this,arguments)},create_table_at_beginning_of_text:function(){this.create_table_at_beginning.apply(this,arguments)},create_table_at_end_of_text:function(){this.create_table_at_end.apply(this,arguments)},create_table_at_end:function(){var t=this.$target.forwardFirst();t.length>0&&"paragraph"!=t.attr("type")&&this.cursorAt(t.attr("id"),0),this.create.apply(this,arguments)},create_table_at_beginning:function(){this.seperate_up_to_paragraph_at_beginning(),this.create.apply(this,arguments)},create_table_at_beginning_of_up_to_paragraph:function(){this.cursorAt(this.$target.closest("paragraph").attr("id"),0),this.create.apply(this,arguments)},create_table_at_end_of_up_to_paragraph:function(){this.cursorAt(this.$target.closest("paragraph").attr("id"),1),this.create.apply(this,arguments)},create_table_at_empty_paragraph:function(){this.create_table_at_beginning_of_paragraph.apply(this,arguments)},create_row:function(t){var e=t.where;this.emit.apply(this,["create_row",[e]].concat(Array.prototype.slice.call(arguments)))},create_column:function(t){var e=t.where;this.emit.apply(this,["create_column",[e]].concat(Array.prototype.slice.call(arguments)))}},un={update:function(t){var e=this,n=t.id,r=t.type,i=c()(t,["id","type"]);this.seperateSelection();var o=this.selection,a=o.start,s=o.end;r||(r=Object.keys(i)[0],i=i[r]);var u,l,p=n?[n]:(u=e.$("#".concat(a.id)),l=e.$("#".concat(s.id)),function(t,e){return a.id==s.id?t:t.add(t.forwardUntil(e)).add(e.parents()).add(e)}(u,l).add(u.parents()).filter(r).add(u.add(l).find(r)).toArray());try{p.forEach((function(t){e.cursorAt(t,0,t,0,void 0,!1),e.emit("update",e.conds,i)}))}finally{this.cursorAt(a.id,a.at,s.id,s.at)}return this}},ln={enter_at_text:function(){this.seperate_at_text_for_end();var t=this.$target.forwardFirst();this.cursorAt(t.attr("id"),0);try{this.enter()}finally{this.cursorAt(t.attr("id"),0)}},enter_at_beginning_of_text:function(){0==this.$target.prev().length?(this.cursorAt(this.$target.parent().attr("id"),0),this.enter()):this.enter_at_beginning()},enter_at_empty_text:function(){this.enter_at_beginning()},enter_at_empty_up_to_cell:function(){this.enter_at_beginning_of_up_to_table()},enter_at_beginning_of_table:function(){this.enter_at_beginning_of_up_to_table()},enter_at_beginning_of_up_to_table:function(){0==this.$target.closest("table,paragraph").backwardFirst("paragraph").length?this.create_first_paragraph():this.enter_at_beginning()},enter_at_beginning:function(){this.seperate_up_to_paragraph_at_beginning()},enter_at_empty_paragraph:function(){this.enter_at_empty_up_to_paragraph()},enter_at_empty_up_to_paragraph:function(){this.enter_at_end_of_up_to_paragraph()},enter_at_beginning_of_paragraph:function(){this.enter_at_beginning_of_up_to_paragraph()},enter_at_beginning_of_up_to_paragraph:function(){var t=this,e=this.target.closest(this.PARAGRAPH_),n=e.clone().insertBefore(e);n.children(":not(".concat(this.PR,")")).remove();var r=this.file.renderChanged(n),i=this.$target.closest("paragraph"),o=i.parent();this.content.updateIn([o.attr("id"),"children"],(function(e){return t.content.setIn([r.id,"parent"],o.attr("id")),e.insert(e.indexOf(i.attr("id")),r.id)}))},enter_at_end:function(){var t=this.$target.forwardFirst();t.closest("paragraph").is(this.$target.closest("paragraph"))&&(this.cursorAt(t.attr("id"),0),this.enter())},enter_at_end_of_paragraph:function(){this.enter_at_end_of_up_to_paragraph()},enter_at_end_of_up_to_paragraph:function(){var t=this,e=this.target.closest(this.PARAGRAPH_),n=e.clone().insertAfter(e);n.children(":not(".concat(this.PR,")")).remove();var r=this.file.renderChanged(n),i=this.$target.closest("paragraph"),o=i.parent();this.content.updateIn([o.attr("id"),"children"],(function(e){return t.content.setIn([r.id,"parent"],o.attr("id")),e.insert(e.indexOf(i.attr("id"))+1,r.id)})),this.cursorAt(r.id,0)}},pn={type_at_text:function(t){var e=this.target,n=this.selection.start,r=n.id,i=n.at,o=e.text();e.text(o.substring(0,i)+t+o.substring(i)),this.file.renderChanged(e),this.cursorAt(r,i+t.length)},type_at_empty_text:function(t){this.file.renderChanged(this.target.text(t)),this.cursorAt(this.selection.start.id,t.length)}},hn={backspace:function(){var t=this.selection,e=t.start,n=t.end;return e.id==n.id&&e.at==n.at?this.emit.apply(this,["backspace",this.conds].concat(Array.prototype.slice.call(arguments))):this.remove.apply(this,arguments),this.clean(),this},backspace_at_text:function(){var t=this.selection.start,e=t.id,n=t.at,r=this.target,i=r.text();r.text(i.substring(0,n-1)+i.substring(n)),this.file.renderChanged(r),this.cursorAt(e,n-1)},backspace_at_empty_text:function(){var t=this.$target.backwardFirst(this.cursorable);t.length&&(this.cursorAtEnd(t.attr("id")),this.backspace.apply(this,arguments))},paragraphHasIndentSetting:function(){throw new Error("paragraphHasIndentSetting implementation")},backspace_at_beginning_of_paragraph:function(){this.backspace_at_beginning_of_up_to_paragraph()},backspace_at_beginning_of_up_to_paragraph:function(){var t=this.$target.closest("paragraph");if(t.attr("numId"))this.backspace_at_beginning_of_up_to_numbering_paragraph();else if(this.paragraphHasIndentSetting())this.backspace_at_beginning_of_up_to_indent_paragraph();else{var e=t.backwardFirst("table, paragraph");if("paragraph"==e.attr("type")){var n=e.attr("id"),r=this.file.getNode(n),i=t.parent(),o=e.children().length-1;r.append(this.target.closest(this.PARAGRAPH_).remove().children(":not(".concat(this.PR,")"))),this.file.renderChanged(r),this.content.updateIn([i.attr("id"),"children"],(function(t){return t.remove(t.indexOf(n)+1)}));var a=e.children().eq(o+1);a.length?this.cursorAt(a.attr("id"),0):this.cursorAtEnd(n)}}},backspace_at_beginning:function(){var t=this.selection.start,e=this.$target.backwardFirst(this.cursorable);if(0!=e.length){var n=e.attr("id");try{this.cursorAtEnd(n),this.backspace.apply(this,arguments)}finally{this.cursorAt(t.id,t.at)}}},backspace_at_end:function(){var t=this.selection.start,e=this.$target.findLast(this.cursorable);e.length>0?(this.cursorAtEnd(e.attr("id")),this.backspace.apply(this,arguments)):(this.cursorAt(t.id,0,t.id,1,void 0,!1),this.remove())},backspace_at_empty:function(){this.backspace_at_beginning.apply(this,arguments)},backspace_at_empty_up_to_paragraph:function(){this.backspace_at_empty_paragraph.apply(this,arguments)},backspace_at_empty_paragraph:function(){this.backspace_at_beginning_of_up_to_document.apply(this,arguments)},backspace_at_empty_up_to_document:function(){this.backspace_at_beginning_of_up_to_document.apply(this,arguments)},backspace_at_beginning_of_up_to_document:function(){this.backspace_at_beginning_of_up_to_paragraph.apply(this,arguments)},backspace_at_empty_up_to_cell:function(){this.backspace_at_beginning_of_up_to_cell.apply(this,arguments)},backspace_at_beginning_of_up_to_cell:function(){var t=this.$target.closest("paragraph");t.attr("numId")?this.backspace_at_beginning_of_up_to_numbering_paragraph.apply(this,arguments):this.paragraphHasIndentSetting()&&this.backspace_at_beginning_of_up_to_indent_paragraph.apply(this,arguments)}},fn={delete:function(){var t=this.selection,e=t.start,n=t.end;return e.id==n.id&&e.at==n.at?this.emit.apply(this,["delete",this.conds].concat(Array.prototype.slice.call(arguments))):this.remove.apply(this,arguments),this.clean(),this},delete_at_text:function(){var t=this.selection.start,e=(t.id,t.at),n=this.target,r=n.text();n.text(r.substring(0,e)+r.substring(e+1)),this.file.renderChanged(n)},delete_at_end_of_text:function(){this.delete_at_end.apply(this,arguments)},delete_at_empty_text:function(){this.delete_at_end.apply(this,arguments)},delete_at_end:function(){var t=this.$target.forwardFirst(this.cursorable);t.length>0&&(this.cursorAt(t.attr("id"),0),this.delete.apply(this,arguments))},delete_at_end_of_paragraph:function(){this.delete_at_end_of_up_to_paragraph.apply(this,arguments)},delete_at_end_of_up_to_paragraph:function(){var t=this.$target.closest("paragraph"),e=t.forwardFirst("table,paragraph");if("paragraph"==e.attr("type")){var n=this.file.getNode(t.attr("id")),r=this.file.getNode(e.attr("id"));n.append(r.children(":not(".concat(this.PR,")"))),e.remove(),this.file.renderChanged(n)}},delete_at_end_of_up_to_document:function(){},delete_at_empty_up_to_paragraph:function(){var t=this.$target.closest("paragraph"),e=t.backwardFirst("paragraph");t.remove(),this.file.getNode(t.attr("id")).remove(),this.cursorAt(e.attr("id"),1)},delete_at_empty_paragraph:function(){this.delete_at_empty_up_to_paragraph.apply(this,arguments)},delete_at_empty_up_to_document:function(){},delete_at_beginning:function(){var t=this.selection.start.id;this.cursorAt(t,0,t,1),this.remove()}},dn={},yn={forward_at_text:function(){var t=this.selection.start,e=t.id,n=t.at;this.cursorAt(e,n+1)},forward_at_end_of_text:function(){this.forward_at_end()},forward_at_end_of_paragraph_up_to_document:function(){},forward_at_end:function(){var t=this.$target.forwardFirst(this.cursorable);t.length>0&&this.cursorAt(t.attr("id"),0)},forward_at_empty:function(){this.forward_at_end()},forward_at_empty_up_to_paragraph:function(){this.forward_at_end()},forward_at_empty_up_to_document:function(){},forward_at_beginning:function(){this.cursorAtEnd(this.selection.start.id),this.forward()},forward_at_beginning_of_paragraph:function(){var t=this.$target.findFirst(this.cursorable);t.length>0?(this.cursorAt(t.attr("id"),0),this.forward()):this.forward_at_end()}},gn={backward_at_text:function(){var t=this.selection.start,e=t.id,n=t.at;this.cursorAt(e,n-1)},backward_at_beginning_of_text:function(){this.backward_at_beginning()},backward_at_beginning:function(){var t=this.$target.backwardFirst(this.cursorable);if(t.length>0)switch(t.attr("type")){case"text":return this.cursorAt(t.attr("id"),t.text().length-1);default:this.cursorAt(t.attr("id"),0)}},backward_at_empty:function(){this.backward_at_beginning()},backward_at_end:function(){this.cursorAt(this.$target.attr("id"),0)},backward_at_beginning_of_up_to_paragraph:function(){var t=this.$target.closest("paragraph").backwardFirst("paragraph");this.cursorAt(t.attr("id"),1)},backward_at_beginning_of_up_to_document:function(){},backward_at_empty_paragraph:function(){this.backward_at_empty_up_to_paragraph()},backward_at_empty_up_to_paragraph:function(){this.backward_at_beginning_of_up_to_paragraph()},backward_at_empty_up_to_document:function(){},backward_at_end_of_paragraph:function(){var t=this.$target.findLast(this.cursorable);"text"==t.attr("type")?this.cursorAt(t.attr("id"),t.text().length-1):this.cursorAt(t.attr("id"),0)}},vn={remove:function(){var t=this,e=arguments,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.type;if(r)return this.emit.apply(this,["remove",[].concat(this.conds,[""]).map((function(t){return r.toLowerCase()+(t&&"_")+t}))].concat(Array.prototype.slice.call(arguments))),this;var i=this.selection,o=i.start,a=i.end;if(o.id==a.id)return o.at!==a.at&&this.emit.apply(this,["remove",this.conds].concat(Array.prototype.slice.call(arguments))),this;try{this.seperateSelection();var s=this.selection,c=s.start,u=s.end,l=this.$("#"+c.id).backwardFirst(this.cursorable),p=this.$("#"+u.id).forwardFirst(this.cursorable),h=this.$target.to("#"+u.id);if(h.toArray().forEach((function(n){t.selectWhole(n),t.emit.apply(t,["remove",t.conds].concat(e))})),0==l.length&&0==p.length)return void this.create_first_paragraph();if(l.length>0){if(this.cursorAtEnd(l.attr("id")),p.length>0){this.cursorAt(this.selection.start.id,this.selection.start.at,p.attr("id"),0);var f=this.selection.end,d=this.$("#"+f.id).parents(),y=this.$target.closest(d),g=d.slice(0,d.indexOf(y)+1).filter("paragraph").length>0,v=y.attr("type"),_=[];g&&_.push("in_paragraph"),_.push("up_to_".concat(v)),_.push("up_to_same_grand_parent"),this.emit("merge",_)}}else p.length>0&&this.cursorAt(p.attr("id"),0)}finally{this.content.has(o.id)&&this.cursorAt(o.id,o.at)}return this},remove_at_text:function(){var t=this.selection,e=t.start,n=e.id,r=e.at,i=t.end.at,o=Math.min(r,i),a=Math.max(r,i),s=this.target,c=s.text();s.text(c.substring(0,o)+c.substring(a)),this.file.renderChanged(this.file.getNode(n)),this.cursorAt(n,o)},remove_at_whole_text:function(){this.remove_at_whole.apply(this,arguments)},remove_at_whole:function(){var t=this;this.safeCursor((function(){t.$target.remove(),t.target.remove()}))},remove_at_whole_paragraph_up_to_document:function(){this.$target.remove(),this.target.remove(),this.create_first_paragraph()},remove_at_beginning_of_up_to_paragraph:function(){var t=this.$target.closest("paragraph");this.remove_whole(),this.cursorAt(t.attr("id"),0)},remove_cell:function(){},remove_column:function(){},remove_row:function(){var t=this.$target.closest("row");t.length>0&&(1==t.closest("table").find("row").length?this.remove_table():(this.selectWhole(t.attr("id")),this.remove_at_whole()))},remove_table:function(){var t=this.$target.closest("table");t.length>0&&(this.selectWhole(t.attr("id")),this.remove_at_whole())}},_n=function(t){function e(){var t;return l()(this,e),(t=d()(this,g()(e).apply(this,arguments))).PR="__unknown",t.PARAGRAPH="paragraph",t.TEXT="text",t.InlineContainers="",Object.assign(i()(t),sn,cn,un,ln,pn,hn,fn,dn,yn,gn,vn),t}return _()(e,t),h()(e,[{key:"merge_in_paragraph",value:function(){var t=this.selection,e=t.start;t.end;this.cursorAt(e.id,e.at)}},{key:"merge_up_to_same_grand_parent",value:function(){var t=this.selection,e=t.start,n=t.end,r=this.target.closest(this.PARAGRAPH_),i=this.file.getNode(n.id).closest(this.PARAGRAPH_);r.append(i.children(":not(".concat(this.PR,")"))),this.$("#".concat(n.id)).remove(),i.remove(),this.file.renderChanged(r),this.cursorAt(e.id,e.at)}},{key:"create_first_paragraph",value:function(){throw new Error("create_first_paragraph")}},{key:"TEXT_",get:function(){return this.TEXT.replace(":","\\:")}},{key:"PARAGRAPH_",get:function(){return this.PARAGRAPH.replace(":","\\:")}}]),e}(an);an.xml=_n;var mn=an;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}function wn(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?bn(n,!0).forEach((function(e){b()(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}var On=function(){function t(){l()(this,t)}return h()(t,[{key:"getType",value:function(){return this.constructor.getType()}},{key:"getTypeName",value:function(){return this.constructor.getTypeName()}},{key:"getTypeExt",value:function(){return this.constructor.getTypeExt()}},{key:"getTypeMimeType",value:function(){return this.constructor.getTypeMimeType()}},{key:"isTypeOf",value:function(t){return this instanceof t}},{key:"editable",value:function(){return!1}},{key:"makeId",value:function(t){return rt()}},{key:"parse",value:function(t){t.data,c()(t,["data"]);return Promise.reject(new Error("need implementation to parse file {data}"))}},{key:"release",value:function(){}},{key:"transform",value:function(t){if(this.constructor.HOCs){var e=this.constructor.HOCs;return Object.keys(e).reduce((function(n,r){return n[r]=e[r](t),n}),wn({},t))}return wn({},t)}},{key:"render",value:function(t,e){return"Input.render should be implemented"}},{key:"getFontList",value:function(){return[]}},{key:"name",get:function(){return this.props&&this.props.name}},{key:"type",get:function(){return this.getType()}},{key:"typeName",get:function(){return this.getTypeName()}},{key:"typeExt",get:function(){return this.getTypeExt()}},{key:"mimeType",get:function(){return this.getTypeMimeType()}}],[{key:"support",value:function(t){return!1}},{key:"getType",value:function(){return this.defaultProps.type}},{key:"getTypeName",value:function(){return this.defaultProps.name}},{key:"getTypeExt",value:function(){return this.defaultProps.ext}},{key:"getTypeMimeType",value:function(){return this.defaultProps.mimeType}},{key:"isWeEditType",get:function(){return!0}}]),t}();b()(On,"propTypes",{type:A.a.string.isRequired,name:A.a.string.isRequired,ext:A.a.string.isRequired,mimeType:A.a.string.isRequired});var kn=function(t){function e(){return l()(this,e),d()(this,g()(e).apply(this,arguments))}return _()(e,t),h()(e,[{key:"editable",value:function(){return!0}},{key:"stream",value:function(t){throw new Error("not support")}},{key:"renderNode",value:function(t,e,n){}},{key:"startTransaction",value:function(){var t;if(this.doc.startTransaction)return(t=this.doc).startTransaction.apply(t,arguments)}},{key:"commit",value:function(){var t;if(this.doc.commit)return(t=this.doc).commit.apply(t,arguments)}},{key:"rollback",value:function(){var t;this.doc.rollback&&(t=this.doc).rollback.apply(t,arguments)}},{key:"onChange",value:function(t,e){var n=e.type,r=e.payload,i=[t],o=He()(this.constructor.Reducer,i);switch(n){case"we-edit/init":o.init(r);break;case"we-edit/text/TYPE":o.type(r);break;case"we-edit/text/DELETE":o.delete(r);break;case"we-edit/text/BACKSPACE":o.backspace(r);break;case"we-edit/text/TAB":o.tab(r);break;case"we-edit/text/ENTER":o.enter(r);break;case"we-edit/entity/CREATE":o.create(r);break;case"we-edit/entity/UPDATE":case"we-edit/selection/UPDATE":o.update(r);break;case"we-edit/selection/COPY":o.copy(r);break;case"we-edit/selection/PASTE":o.paste(r);break;case"we-edit/selection/CUT":o.cut(r);break;case"we-edit/selection/MOVE":o.move(r);break;case"we-edit/selection/REMOVE":o.remove(r);break;case"we-edit/selection/EXTEND":o.extend(r);break;case"we-edit/history/UNDO":o.undo(r);break;case"we-edit/cursor/FORWARD":o.forward(r);break;case"we-edit/cursor/BACKWARD":o.backward(r);break;case"we-edit/selection/SELECTED":case"we-edit/selection/STARTEDAT":var a=Ie(R(t),e),s=a.start,c=a.end,u=a.cursorAt;o.cursorAt(s.id,s.at,c.id,c.at,u);break;default:return!0}return o.state()}}],[{key:"createStyles",value:function(){return{}}}]),e}(On);b()(kn,"EventHandler",mn);var An,Pn,En=Z({Viewable:Object.assign(On,{install:function(t){En.install(this,t)},uninstall:function(){En.uninstall(this)}}),Editable:Object.assign(kn,{install:function(t){En.install(this,t)},uninstall:function(){En.uninstall(this)}}),parse:function(t){var e=this.resolveFileType(t),n=this.get(e);if(n){var r=new n;return Promise.resolve(r.parse(t)).then((function(t){return function(t,e){var n=rt(),r=e.transform.bind(e),i=r(De),o=ot()((function(t,e){return new Ve(t,"we-edit",(function(t){return t["we-edit"].docs[e].state}))})),s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t){return t},n=ze(e),r=Be(n,e,i),o=(new x.Map).withMutations((function(t){return e.render(n(t),i)})),a=U(r),s=H(e,o);return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{type:"we-edit/init"};return e=(e=(e=a(e,n)).set("statistics",Ne(e.get("statistics"),n))).set("ui",We(e.get("ui"),n)),t(e,n)}},u=Object(at.compose)(Object(at.setDisplayName)("DocStore"),Object(at.getContext)({store:A.a.any}))((function(t){var i=t.children,u=t.store,l=t.release,p=void 0===l||l,h=t.reducer,f=c()(t,["children","store","release","reducer"]),d=null;return u?u=o(u,n):(u=K(s(h)),d=function(){return e.release()}),O.a.createElement(J,{store:u},O.a.createElement(Ue,a()({doc:e,onQuit:p?d:null,transformer:r},f),i))}));return Object.assign(e,{id:n,doc:t,buildReducer:s,Store:u,toJSON:function(){return this.name}})}(t,r)}))}throw new Error("we cannot edit ".concat(t))},resolveFileType:function(t){var e=this,n=arguments,r=(t.data,t.type),i=t.mimeType,o=t.ext,a=t.name;return r||(a&&!o&&(o=a.split(".").pop().trim()),Object.keys(this.supports).reverse().reduce((function(t,r){if(t)return t;var a=e.get(r);if(a){if(o&&a.getTypeExt()==o)return a.getType();if(i&&a.getTypeMimeType()==i)return a.getType();if(a.support&&a.support(n[0]))return a.getType()}}),null))}},"input format"),xn=En;function jn(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 Cn=function(t){function e(){var t;return l()(this,e),(t=d()(this,g()(e).apply(this,arguments))).state={file:null},t.onLoad=t.onLoad.bind(i()(t)),t}return _()(e,t),h()(e,[{key:"getChildContext",value:function(){return{onLoad:this.onLoad}}},{key:"isInWeEditDomain",value:function(){var t=this.context.store;return!!t&&!!t.getState()[Ft]}},{key:"render",value:function(){var t=this.state,e=t.file,n=t.doc;if(!this.isInWeEditDomain()&&e&&n){var r=this.props,i=r.readonly,o=r.release;return O.a.createElement(n.Store,a()({readonly:i,release:o},{key:n.id}),this.props.children)}var s=this.props,u=s.type,l=s.children;c()(s,["type","children"]);if(u){var p=this.constructor.get(u,!0);if(p)return O.a.createElement(p,a()({},this.props,{onLoad:this.onLoad.bind(this)}))}return O.a.createElement(w.Fragment,null,l||null)}},{key:"onLoad",value:function(t){var e=this,n=t.error,r=c()(t,["error"]),i=this.props,o=i.onLoad,a=i.reducer,s=i.type;if(n){if(console.error(n),!this.isInWeEditDomain())throw n;return this.context.store.dispatch(Wt.MESSAGE({type:"error",message:n.message})),void o()}return xn.parse(r).then((function(t){e.isInWeEditDomain()?e.context.store.dispatch(Wt.ADD(t,a)):e.setState({file:r,doc:t});r.data,r.stream;var n=c()(r,["data","stream"]);o(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?jn(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({type:s},n))})).catch((function(t){console.error(t),e.context.store.dispatch(Wt.MESSAGE({type:"error",message:t.message}))}))}}]),e}(w.PureComponent);b()(Cn,"displayName","loader"),b()(Cn,"propTypes",{type:A.a.string.isRequired,reducer:A.a.func,onLoad:A.a.func}),b()(Cn,"defaultProps",{onLoad:function(t){return t}}),b()(Cn,"contextTypes",{store:A.a.object}),b()(Cn,"childContextTypes",{onLoad:A.a.func}),b()(Cn,"Base",(Pn=An=function(t){function e(){var t;return l()(this,e),((t=d()(this,g()(e).apply(this,arguments))).context.inRender||t.props.now||"undefined"==typeof document)&&(t.render=function(){return null},t.componentDidMount=function(){t.doLoad()}),t}return _()(e,t),h()(e,null,[{key:"install",value:function(t){Cn.install(this,t)}},{key:"uninstall",value:function(){Cn.uninstall(this)}}]),h()(e,[{key:"render",value:function(){return null}},{key:"doLoad",value:function(){var t=this;return Promise.resolve(this.load()).then((function(e){return t.props.onLoad(e),e}))}},{key:"load",value:function(){return new pe.Readable({})}}]),e}(w.Component),b()(An,"propTypes",{type:A.a.string.isRequired}),b()(An,"contextTypes",{inRender:A.a.bool}),Pn));var Tn,Sn,Dn=Z(Cn,"loader"),Rn=n(26),$n=n.n(Rn);function In(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 qn(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?In(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):In(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Fn=Y((function(t){t.get("content");var e=R(t),n=e.cursorAt;return{focus:c()(e,["cursorAt"])[n].id}}))(function(t){function e(){var t,n;l()(this,e);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(o))),b()(i()(n),"state",{show:!0}),n}return _()(e,t),h()(e,[{key:"render",value:function(){var t=this,e=this.props,n=e.name,r=e.id,i=e.children,o=e.isFocus,a=e.focus,s=e.dispatch,u=e.textContent,l=e.onClick,p=void 0===l?function(t){s("string"==typeof u?z.SELECT(r,0,r,u.length):z.SELECT(r))}:l,h=c()(e,["name","id","children","isFocus","focus","dispatch","textContent","onClick"]),f=this.state.show;i&&(Array.isArray(i)?i=O.a.createElement("dl",{style:{marginLeft:15,marginTop:0,marginBottom:0,display:f?"":"none"}},i):"string"==typeof i&&(i=null)),h.style=qn({},h.style,{userSelect:"none"});var d={};return o(a)&&(d.background="lightblue"),O.a.createElement(w.Fragment,null,n&&O.a.createElement("dt",h,O.a.createElement("span",{onClick:function(e){return t.setState({show:!f})},style:{display:"inline-block",width:20,textAlign:"center"}},!!i&&(f?"-":"+")),O.a.createElement("span",{style:d,onClick:p},n)),i)}}]),e}(w.PureComponent)),Nn=function(t,e){return t===e||t.equals&&t.equals(e)},Ln=Object(at.compose)(Object(at.setDisplayName)("DocumentTree"),Y((function(t){return{content:t.get("content")}})))((Sn=Tn=function(t){function e(){var t,n,r=this;l()(this,e);for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return n=d()(this,(t=g()(e)).call.apply(t,[this].concat(a))),b()(i()(n),"getFocus",ot()((function(t,e,r){if(t.has(r)){e=n.getFilter(e);for(var i=r;i&&!e(t.get(i).toJS());)i=N(t,i);if(i)return t.get(i).toJS()}return null}),Nn)),b()(i()(n),"getDocument",ot()((function(t,e,i,o){i=i||O.a.createElement(r.constructor.Node,null);var a=function(r){return function(i){var o=n.getFocus(t,e,i);return!!o&&o.id==r}};o=o||function(t){var e=t.id,n=t.type;t.props;return{id:e,name:n}};return n.constructor.createDocument(t,n.getFilter(e),(function(t,e,n,r){return O.a.cloneElement(i,qn({},o({id:t,type:e,props:n}),{key:t,id:t,children:r,isFocus:a(t),textContent:"string"==typeof r?r:void 0}))}))}),Nn)),b()(i()(n),"getFilter",ot()((function(t){if("string"==typeof t){var e=t;t=function(t){return $n()(t.type||"",e)}}return"function"==typeof t?t:function(e){return!!t}}))),n}return _()(e,t),h()(e,[{key:"shouldComponentUpdate",value:function(t){if(ct(t,this.props))return!1;var e=t.content,n=c()(t,["content"]),r=this.props,i=r.content,o=c()(r,["content"]);return!ct(n,o)||!e.equals(i)}},{key:"render",value:function(){var t=this.props,e=t.content,n=t.filter,r=void 0===n?"*":n,i=t.children,o=t.node,a=void 0===o?i:o,s=t.toNodeProps,c=this.getDocument(e,r,a,s);return O.a.createElement(w.Fragment,null,c.props.children)}}],[{key:"createDocument",value:function(t,e,n){var r=function(r){if(t.has(r)){var o=t.get(r).toJS(),a=o.type,s=o.props,c=o.children;return"root"==r||e(o)?n(r,a,s,Array.isArray(c)?i(c):c):Array.isArray(c)?i(c):null}return null},i=function(t){return 0==(t=t.map((function(t){return r(t)})).filter((function(t){return!!t&&(!Array.isArray(t)||t.length>0)})).reduce((function(t,e){return Array.isArray(e)?t.splice.apply(t,[t.length,0].concat(e)):t.splice(t.length,0,e),t}),[])).length?null:t};return r("root")}}]),e}(w.Component),b()(Tn,"propTypes",{content:A.a.any,node:A.a.element,toNodeProps:A.a.func}),b()(Tn,"Node",Fn),Sn));function Mn(t){if(!t)return{left:0,top:0,width:0,height:0};var e=t.getBoundingClientRect(),n=e.left,r=e.top,i=e.bottom,o=e.right,a=e.width,s=e.height,c=window,u=c.scrollX,l=c.scrollY,p=Math.floor;return{left:p(n+u),right:p(o+u),top:p(r+l),bottom:p(i+l),height:s,width:a}}function Wn(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 Un(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Wn(n,!0).forEach((function(e){b()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Wn(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var Bn=function(t){return Array.isArray(t)?t:[t]},zn=function(){function t(e,n,r){if(l()(this,t),this._nodes=[],Array.isArray(e)?this._nodes=e.filter((function(t){return O.a.isValidElement(t)})):O.a.isValidElement(e)&&(this._nodes.push(e),r||(r=e)),this.root=r,n)return this.find(n)}return h()(t,[{key:"_asSelector",value:function(e){var n=this;switch(At()(e)){case"function":return e;case"string":return Ge(e,(function(t){return new n.constructor(t)}),this.constructor.Selector);case"object":if(e instanceof t)return function(t){return e.has(t)};throw new Error("not supported react-query selector");default:return function(t){return!0}}}},{key:"attr",value:function(t,e){switch(arguments.length){case 2:if(!this.length)return this;var n=this._nodes[0];switch(t){case"type":return this;default:return this.replace(n,O.a.cloneElement(n,b()({},t,e)))}default:if(!this.length)return null;var r=this._nodes[0];switch(t){case"type":return r.type;default:return r.props[t]}}}},{key:"replace",value:function(e,n,r){e instanceof t&&(e=e.get(0)),n instanceof t&&(n=n.get(0)),console.assert(O.a.isValidElement(e)),console.assert(O.a.isValidElement(n));var i=new this.constructor(this.root).findFirstAndParents((function(t){return t==e||void 0})),o=i.first,a=i.parents;console.assert(o.get(0)==e),console.assert(a.length>0);var s=a.reduceRight((function(t,e){var n=t.origin,i=t.cloned,o=[].concat(Bn(e.props.children));switch(o.length){case 1:return{cloned:O.a.cloneElement(e,Un({},r),i),origin:e};default:var a=o.indexOf(n);return o.splice(a,1,i),{origin:e,cloned:O.a.cloneElement(e,Un({children:o},r))}}}),{origin:e,cloned:n}).cloned;return new this.constructor(s)}},{key:"children",value:function(t){var e=this._asSelector(t),n=this._nodes.slice(0,1).reduce((function(t,n){return w.Children.toArray(n.props.children).reduce((function(t,n){return e(n)&&t.push(n),t}),t),t}),[]);return new this.constructor(n,null,this.root)}},{key:"has",value:function(t){var e=this._asSelector(t);return!!this._nodes.find((function(t){return e(t)}))}},{key:"filter",value:function(t){var e=this._asSelector(t);return new this.constructor(this._nodes.filter((function(t){return!!e(t)})),null,this.root)}},{key:"find",value:function(t){var e=this._asSelector(t),n=this._nodes.reduce((function(t,n){return Vn(n,(function(n){var r=e.apply(void 0,arguments);r&&t.push(n)})),t}),[]);return new this.constructor(n,null,this.root)}},{key:"findFirst",value:function(t){for(var e=this._asSelector(t),n=null,r=0,i=this._nodes.length;r<i;r++)n||Vn(this._nodes[r],(function(t){var r=e.apply(void 0,arguments);return r&&(n=t),r}));return new this.constructor(n,null,this.root)}},{key:"findFirstAndParents",value:function(t){t=this._asSelector(t);var e=[],n=this.findFirst((function(n,r){if(r){var i=e.indexOf(r);-1!=i&&e.splice(i),e.push(r)}return t(n,e)}));return 0==n.length&&e.splice(0),{first:n,parents:e}}},{key:"findLast",value:function(t){for(var e=this._asSelector(t),n=null,r=this._nodes.length-1;r>=0;r--)n||Vn(this._nodes[r],(function(t){var r=e.apply(void 0,arguments);return r&&(n=t),r}),!0);return new this.constructor(n,null,this.root)}},{key:"findLastAndParents",value:function(t){t=this._asSelector(t);var e=[],n=this.findLast((function(n,r){if(r){var i=e.indexOf(r);-1!=i&&e.splice(i),e.push(r)}return t(n,e)}));return 0==n.length&&e.splice(0),{last:n,parents:e}}},{key:"eq",value:function(t){return new this.constructor([this._nodes[t]],null,this.root)}},{key:"get",value:function(t){return this._nodes[t]}},{key:"toArray",value:function(){return[].concat(this._nodes)}},{key:"length",get:function(){return this._nodes.length}}]),t}();function Vn(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(O.a.isValidElement(t)){if(r){var i=e(t);if(!0===i)return!0;if(!1===i)return!1}if("string"!=typeof t.props.children){var o=Bn(t.props.children).filter((function(t){return!!t}));if("string"!=typeof o[0])return o.length>0?!!o["find".concat(n?"Last":"")]((function(r){var i=e(r,t);return!0===i||!1!==i&&!!Vn(r,e,n,!1)})):void 0}}}function Kn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.unshift((t.parent||t.root).children.indexOf(t)),t.parent&&Kn(t.parent,e),e}b()(zn,"Selector",{"#":function(t){return function(e){return e.props.id==t}},"[":function(t,e){return function(n){return void 0===e?Object.keys(n.props).includes(t):n.props[t]==e}},".":function(t){return function(e){return(e.props.className||"").split(/\s+/).includes(t)}},type:function(t){return function(e){return"string"==typeof e.type?e.type===t:e.type.displayName===t}}});var Hn={save:function(){},applyPatch:function(t){},mergePatches:function(t,e){Array.isArray(t)||(t=[t]),1==t.length&&e.length>0&&function(t,e){if(t.path.join(",")==e.path.join(",")&&t.op==e.op)switch(t.op){case"attr":case"data":case"css":case"prop":case"val":case"text":case"replaceWith":return!0}return!1}(t[0],e[e.length-1])||e.splice.apply(e,[e.length,0].concat(t))},attrPatch:function(t,e){var n=this;return this.map((function(e,r){return{op:"attr",path:Kn(r,[t]),value:n.eq(e).attr(t)}})).get()},attrApplyPatch:function(t){var e=t.path,n=t.value,r=void 0===n?null:n,i=t.key,o=void 0===i?e.pop():i;this.path(e).attr(o,r)},cssPatch:function(t,e){var n=this;return this.map((function(e,r){return{op:"css",path:Kn(r,[t]),value:"string"==typeof t&&n.eq(e).css(t)}})).get()},cssApplyPatch:function(t){var e,n=t.path,r=t.value,i=void 0===r?"":r,o=t.key,a=void 0===o?n.pop():o,s=[a];"string"==typeof a&&s.push(i),(e=this.path(n)).css.apply(e,s)},propPatch:function(t,e){var n=this;return this.map((function(e,r){return{op:"prop",path:Kn(r,[t]),value:n.eq(e).prop(t)}})).get()},propApplyPatch:function(t){var e=t.path,n=t.value,r=void 0===n?null:n,i=t.key,o=void 0===i?e.pop():i;this.path(e).prop(o,r)},dataPatch:function(t,e){var n=this;return this.map((function(e,r){return{op:"data",path:Kn(r,[t]),value:n.eq(e).data(t)}})).get()},dataApplyPatch:function(t){var e=t.path,n=t.value,r=void 0===n?null:n,i=t.key,o=void 0===i?e.pop():i;this.path(e).data(o,r)},textPatch:function(t){var e=this;return this.map((function(t,n){return{op:"text",path:Kn(n),value:e.eq(t).text()}})).get()},textApplyPatch:function(t){var e=t.path,n=t.value,r=void 0===n?"":n;this.path(e).text(r)},valPatch:function(t){var e=this;return this.map((function(t,n){return{op:"val",path:Kn(n),value:e.eq(t).val()}})).get()},valApplyPatch:function(t){var e=t.path,n=t.value,r=void 0===n?"":n;this.path(e).val(r)},removeAttrPatch:function(t){return Hn.attrPatch.call(this,t,null)},removeClassPatch:function(t){return Hn.attrPatch.call(this,"class")},toggleClassPatch:function(t){return Hn.attrPatch.call(this,"class")},addClassPatch:function(t){return Hn.attrPatch.call(this,"class")},appendPatch:function(t){return this.map((function(t,e){return{op:"splice",path:Kn(e,[(e.children||[]).length])}})).get()},spliceApplyPatch:function(t){var e=t.path,n=t.from,r=void 0===n?e.pop():n,i=t.value,o=this.path(e).contents();o.slice(r,"function"==typeof i?i(o.length):i).remove()},prependPatch:function(){return this.map((function(t,e){return{op:"splice",path:Kn(e,[0]),value:-(e.children||[]).length}})).get()},afterPatch:function(){var t=this;return this.map((function(e,n){var r=Kn(n),i=1==r.length,o=r[r.length-1]=r[r.length-1]+1,a=(i?t.constructor.root():t.eq(e).parent()).contents().length;return{op:"splice",path:r,value:function(t){return o+t-a}}})).get()},beforePatch:function(){var t=this;return this.map((function(e,n){var r=Kn(n),i=1==r.length,o=r[r.length-1],a=(i?t.constructor.root():t.eq(e).parent()).contents().length;return{op:"splice",path:r,value:function(t){return o+t-a}}})).get()},insertAfterPatch:function(t){var e=this;return Hn.afterPatch.call(this.constructor(t).filter((function(t,n){return!function t(n){return n.parent?t(n.parent):-1==e.constructor.root().contents().index(n)}(n)})))},insertBeforePatch:function(t){var e=this;return Hn.beforePatch.call(this.constructor(t).filter((function(t,n){return!function t(n){return n.parent?t(n.parent):-1==e.constructor.root().contents().index(n)}(n)})))},replaceWithPatch:function(t){var e=this;return this.map((function(n,r){return{op:"replaceWith",path:Kn(r),value:e.eq(n).clone(),len:t}})).get()},replaceWithApplyPatch:function(t){var e=t.path,n=t.value,r=t.len,i=void 0===r?1:r,o=this.path(e);i>1&&new Array(i-1).fill(0).forEach((function(t){o.next().remove()})),o.replaceWith(n)},emptyPatch:function(){return Hn.replaceWithPatch.bind(this)()},htmlPatch:function(){return Hn.replaceWithPatch.bind(this)()},wrapPatch:function(t){return Hn.replaceWithPatch.bind(this)()},removePatch:function(t){var e=this;return(1==arguments.length?this.filter(t):this).map((function(t,n){return{op:"insert",path:Kn(n),value:e.eq(t).clone()}})).get()},insertApplyPatch:function(t){var e=t.path,n=t.value,r=t.index,i=void 0===r?e.pop():r,o=this.path(e),a=o.contents();a.length-1>=i?a.eq(i).before(n):0==a.length?o.append(n):a.eq(i-1).after(n)}},Gn=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hn,n=[],r=!1,i=function e(n){return n.parent?e(n.parent):-1==t.root().contents().index(n)},o=function(t,r){t=t.filter((function(t,e){return!i(e)}));for(var o,a,s=null,c=arguments.length,u=new Array(c>2?c-2:0),l=2;l<c;l++)u[l-2]=arguments[l];e["".concat(r,"Patch")]?s=(o=e["".concat(r,"Patch")]).call.apply(o,[t].concat(u))||[]:s=(a=e.save).call.apply(a,[t,r].concat(u))||[];e.mergePatches&&e.mergePatches(s,n)},a=function(n){var r,i,o=n.op;e["".concat(o,"ApplyPatch")]?(r=e["".concat(o,"ApplyPatch")]).call.apply(r,[t].concat(Array.prototype.slice.call(arguments))):(i=e.applyPatch).call.apply(i,[t].concat(Array.prototype.slice.call(arguments)))};return Object.assign(t.prototype,{path:function(){return Kn(this.get(0))}}),t.prototype=new Proxy(t.prototype,{get:function(e,n,i){var a=Reflect.get.apply(Reflect,arguments);if(!r)return a;switch(n){case"css":case"data":case"prop":case"attr":return function(t,e){if(void 0===e&&"object"==At()(t)&&!Array.isArray(t))return Object.keys(t).forEach((function(e){return i[n](e,t[e])})),i;if(null!=e&&(o.apply(void 0,[i,n].concat(Array.prototype.slice.call(arguments))),"css,data,prop".split(",").includes(n)))try{return r=!1,a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))}finally{r=!0}return a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"val":return function(){if(arguments.length){o.apply(void 0,[i,n].concat(Array.prototype.slice.call(arguments)));try{return r=!1,a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))}finally{r=!0}}return a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"text":case"removeAttr":case"removeClass":case"addClass":case"toggleClass":case"wrap":return function(){return arguments.length&&o.apply(void 0,[i,n].concat(Array.prototype.slice.call(arguments))),a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"html":case"append":case"prepend":case"after":case"before":return function(){return arguments.length&&(t(arguments[0]).remove(),1==i.length?o.apply(void 0,[i,n].concat(Array.prototype.slice.call(arguments))):i.length>1&&o.apply(void 0,[i.parent(),"replaceWith"].concat(Array.prototype.slice.call(arguments)))),a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"replaceWith":return function(){if(arguments.length){var e=t(arguments[0]).remove().length;1==i.length?o(i,n,e):i.length>1&&o.apply(void 0,[i.parent(),"replaceWith"].concat(Array.prototype.slice.call(arguments)))}return a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"insertAfter":return function(){if(arguments.length){var e=i.length,n=t(arguments[0]);return n.after(i),t(n.map((function(t){return new Array(e-1).fill(0).reduce((function(t,e){return t.add(t.last().next())}),n.eq(t).next()).toArray()})).get())}return a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"insertBefore":return function(){if(arguments.length){var e=i.length,n=t(arguments[0]);return n.before(i),t(n.map((function(t){return new Array(e-1).fill(0).reduce((function(t,e){return t.add(t.last().prev())}),n.eq(t).prev()).toArray()})).get())}return a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"empty":return function(){return o.apply(void 0,[i,n].concat(Array.prototype.slice.call(arguments))),a.call.apply(a,[i].concat(Array.prototype.slice.call(arguments)))};case"remove":return function(){return arguments.length?i.filter.apply(i,arguments).remove():i.each((function(t,e){var r=i.eq(t);return o(r,n),a.call(r)})),i};default:return a}}}),Object.assign(t,{path:function(e){return e&&0!=e.length?e.reduce((function(t,e){return t.contents().eq(e)}),t.root()):t.root()},startTransaction:function(){r=!0},commit:function(){return r=!1,n.splice(0,n.length)},rollback:function(t){return r=!1,(t=t||n).reverse().forEach((function(t){return a(t)})),t.splice(0,t.length)}})},Jn=n(27),Yn=n.n(Jn);function Xn(t){var e=[];var n=null,r=new Promise((function(t,e){var r,i;i=r=function(t){function n(){return l()(this,n),d()(this,g()(n).apply(this,arguments))}return _()(n,t),h()(n,[{key:"getChildContext",value:function(){return{inRender:!0,muiTheme:{}}}},{key:"render",value:function(){return O.a.createElement(w.Fragment,null,this.props.children)}}],[{key:"getDerivedStateFromError",value:function(t){return console.error(t),e(t),null}}]),n}(w.PureComponent),b()(r,"childContextTypes",{inRender:A.a.bool,muiTheme:A.a.object}),n=i})),i=Yn.a.create(O.a.createElement(n,null,function t(n){if(!O.a.isValidElement(n))return n;if(n.type==de){var r,i=n.props.onFinish;e.push(new Promise((function(t,e){r=function(e){try{i.apply(void 0,arguments)}finally{t.apply(void 0,arguments)}}}))),n=O.a.cloneElement(n,{onFinish:r})}return"string"!=typeof n.props.children?O.a.cloneElement.apply(O.a,[n,{}].concat(w.Children.toArray(n.props.children).map((function(e){return t(e)})))):n}(t)));return new Promise((function(t,n){r.catch((function(t){i.unmount(),n([t])})),Promise.all(e).then((function(e){i.unmount();var r=(e=e.reduce((function(t,e){return[].concat(t,e)}),[]).filter((function(t){return!!t}))).filter((function(t){return t instanceof Error}));r.length?n(r,e.filter((function(t){return!(t instanceof Error)}))):t(e)}))}))}n.d(e,"Editor",(function(){return pt})),n.d(e,"Viewer",(function(){return vt})),n.d(e,"Emitter",(function(){return St})),n.d(e,"Representation",(function(){return et})),n.d(e,"WeEdit",(function(){return qt})),n.d(e,"onlyWhen",(function(){return Vt})),n.d(e,"when",(function(){return Kt})),n.d(e,"Cursor",(function(){return se})),n.d(e,"Selection",(function(){return le})),n.d(e,"Stream",(function(){return de})),n.d(e,"Loader",(function(){return Dn})),n.d(e,"DocumentTree",(function(){return Ln})),n.d(e,"ACTION",(function(){return Wt})),n.d(e,"DOMAIN",(function(){return Ft})),n.d(e,"reducer",(function(){return Ut})),n.d(e,"getActive",(function(){return Lt})),n.d(e,"getAll",(function(){return Mt})),n.d(e,"connect",(function(){return Y})),n.d(e,"getContent",(function(){return F})),n.d(e,"getSelection",(function(){return R})),n.d(e,"getFile",(function(){return q})),n.d(e,"getUndos",(function(){return S})),n.d(e,"getRedos",(function(){return D})),n.d(e,"getSelectionStyle",(function(){return $})),n.d(e,"getStatistics",(function(){return I})),n.d(e,"getClientRect",(function(){return Mn})),n.d(e,"shallowEqual",(function(){return ct})),n.d(e,"ReactQuery",(function(){return zn})),n.d(e,"uuid",(function(){return rt})),n.d(e,"transactifyCheerio",(function(){return Gn})),n.d(e,"ContentQuery",(function(){return tn})),n.d(e,"Input",(function(){return xn})),n.d(e,"dom",(function(){return De})),n.d(e,"render",(function(){return Xn}))}]);
2//# sourceMappingURL=index.js.map
\No newline at end of file