!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("slate")):"function"==typeof define&&define.amd?define(["exports","slate"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SlateHyperscript={},t.Slate)}(this,(function(t,e){"use strict";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var o=n((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),i=r(o),u=n((function(t){var e=o.default;t.exports=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports}));r(u);var f=n((function(t){var e=o.default;t.exports=function(t){var r=u(t,"string");return"symbol"===e(r)?r:String(r)},t.exports.__esModule=!0,t.exports.default=t.exports}));r(f);var a=r(n((function(t){t.exports=function(t,e,r){return(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports}))); /*! * is-plain-object * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function c(t){var e,r;return!1!==s(t)&&(void 0===(e=t.constructor)||!1!==s(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf"))}var l=n((function(t){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports}));r(l);var p=n((function(t){t.exports=function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,f=[],a=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(f.push(n.value),f.length!==e);a=!0);}catch(t){s=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw o}}return f}},t.exports.__esModule=!0,t.exports.default=t.exports}));r(p);var d=n((function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{};S(this,r),t=e.call(this),a(v(t),"offset",void 0),a(v(t),"path",void 0);var o=n.offset,i=n.path;return t.offset=o,t.path=i,t}return P(r)}(A),D=function(t){w(r,t);var e=M(r);function r(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S(this,r),t=e.call(this),a(v(t),"offset",void 0),a(v(t),"path",void 0);var o=n.offset,i=n.path;return t.offset=o,t.path=i,t}return P(r)}(A),k=function(t){return T.get(t)};function I(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function B(t){for(var e=1;e=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,f=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){f=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(f)throw i}}}}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1)throw new Error("The hyperscript tag must only contain a single node's worth of children.");var i=x(o,1)[0];if(null==i&&(i={text:""}),!e.Text.isText(i))throw new Error("\n The hyperscript tag can only contain text content as children.");return U.delete(i),Object.assign(i,r),i}var H=function(t){return function(r,n,o){var i,u,f=[],a=C(o);try{for(a.s();!(u=a.n()).done;){var s=u.value;e.Range.isRange(s)?i=s:f.push(s)}}catch(t){a.e(t)}finally{a.f()}var c=W(f),l={},p=t();Object.assign(p,n),p.children=c;var d,h,y=C(e.Node.texts(p));try{for(y.s();!(d=y.n()).done;){var b=x(d.value,2),v=b[0],g=b[1],w=(h=v,E.get(h)),O=k(v);if(null!=w){var m=x(w,1)[0];l.anchor={path:g,offset:m}}if(null!=O){var j=x(O,1)[0];l.focus={path:g,offset:j}}}}catch(t){y.e(t)}finally{y.f()}if(l.anchor&&!l.focus)throw new Error("Slate hyperscript ranges must have both `` and `` defined if one is defined, but you only defined ``. For collapsed selections, use `` instead.");if(!l.anchor&&l.focus)throw new Error("Slate hyperscript ranges must have both `` and `` defined if one is defined, but you only defined ``. For collapsed selections, use `` instead.");return null!=i?p.selection=i:e.Range.isRange(l)&&(p.selection=l),p}};function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function z(t){for(var e=1;e hyperscript tag must have an tag as a child with `path` and `offset` attributes defined.");if(!o||null==o.offset||null==o.path)throw new Error("The hyperscript tag must have a tag as a child with `path` and `offset` attributes defined.");return B({anchor:{offset:n.offset,path:n.path},focus:{offset:o.offset,path:o.path}},e)},text:F},J=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.elements,r=void 0===e?{}:e,n=L(r),o=z(z(z({},G),n),t.creators),i=K(o);return i},K=function(t){return function(e,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i"));null==r&&(r={}),c(r)||(o=[r].concat(o),r={});var f=u(e,r,o=o.filter((function(t){return Boolean(t)})).flat());return f}},L=function(t){var e={},r=function(){var r=t[n];if("object"!==i(r))throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(n,"> tag you passed: ").concat(r));e[n]=function(t,e,n){return q(0,z(z({},r),e),n)}};for(var n in t)r();return e},Q=J();t.createEditor=H,t.createHyperscript=J,t.createText=F,t.jsx=Q}));