/*!
 * @postscriptum.app/core 0.13.5-beta (August 22nd 2023)
 * 
 * 
 * Includes:
 *  - Postcss: http://postcss.org/ (MIT License)
 *  - Hypher: https://github.com/bramstein/hypher (BSD license)
 *  
 * Copyright © 2015-2023 David Rivron
 * Released under the MIT license (https://opensource.org/licenses/mit-license.php))
 */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.postcssPsPrecss = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
module.exports=require("./precss").default;

},{"./precss":2}],2:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importFold=exports.importUnfold=exports.replaceMediaType=exports.styleAttrPlugin=void 0;const postcss=require("postcss"),valueParser=require("postcss-value-parser"),util_1=require("./util"),defaultOptions={defaultPageSize:["210mm","297mm"]},GCPM_CONTENT_FUNCS=["target-text","target-content","target-counter","target-counters","leader","element","string"],SIDES=["top","right","bottom","left"],AREA_CSS_PROPS=["margin","padding","border","outline","grid","display"],CONTENT_PSEUDOS_RE=/::(before|after|marker)\s?/,SINGLE_COLON_PSEUDO_RE=/(^|[^:]):(before|after|first-letter|first-line)/g,PROPS_TO_PREFIX_RE=/^(?:size|page|break-.+|page-break-.+|orphans|widows|bookmark-.+|string-set|position|float|footnote-.+|margin-break|box-decoration-break|bleed|marks|columns|column-.+|hyphens|-ps-.+|-psp-.+)$/,PAGE_BREAKS=["auto","avoid","always","page","left","right","recto","verso"],URI_PROPS_RE=/^(--.+|.+-image|background|list-style|cursor|content|border|border-image-source|mask|-webkit-mask|src|symbols)$/,PSEUDO_TO_ATTR_RE=/:-(ps-breaked-(before|after))/g,FLOAT_PSEUDO_RE=/^(.*)::(-ps-float|footnote)-(marker|call)$/,COLUMNS_PSEUDO_RE=/^(.*)::-ps-columns(\b.+)?$/,NOT_VAL_NODE={type:"word",value:"not"},SPACE_VAL_NODE={type:"space",value:" "},COMMA_VAL_NODE={type:"div",value:","},HREF_VAL_NODE={type:"word",value:"href"};function selectMediaType(e,s){e.walkAtRules(/^media|import\b/,(e=>{e.params=replaceMediaType(e.params,s.mediaType)}))}function replaceMediaType(e,s){const o=valueParser(e),t=[];for(let e=0;e<o.nodes.length;e++){const r=o.nodes[e];if("word"==r.type&&"and"!=r.value)if("not"==r.value){const a=o.nodes[e+2];a.value!=s&&"all"!=a.value||t.push(r,SPACE_VAL_NODE),a.value="all",t.push(a),e+=2}else"only"!=r.value&&(r.value!=s&&"all"!=r.value&&t.push(NOT_VAL_NODE,SPACE_VAL_NODE),r.value="all",t.push(r));else t.push(r)}return valueParser.stringify(t)}function css3Pseudos(e){e.walkRules((e=>{e.selector=e.selector.replace(SINGLE_COLON_PSEUDO_RE,"$1::$2")}))}function replaceAtPageRules(e,s){const o=new Set;e.walkAtRules(/^page\b/,(e=>{const t=postcss.list.comma(e.name.substr(4)+e.params),r=e.parent;for(const a of t){let t="ps-page";const p=a.replace(/:/g," :").split(" ");let n=null;for(const e of p)e&&(":"==e[0]?e.startsWith(":nth(")?t+=":nth-of-type"+e.substr(4):e.startsWith(":first")?t+=n?"[ps-pseudos~=first-of-group][ps-pseudos]":`[ps-pseudos~=${e.substr(1)}][ps-pseudos]`:t+=`[ps-pseudos~=${e.substr(1)}]`:(n=e,t+=`[ps-name=${n}]`));const l=postcss.rule({selector:t});l.source=e.source;const c=postcss.rule({selector:t+" > ps-page-area"});c.source=e.source;for(const t of e.nodes)if("decl"==t.type){const e=t;if("size"==e.prop){const r=getPageSize(e.value,s.defaultPageSize);o.add(r.join(" "));const a=postcss.decl({prop:"--ps-page-width",value:r[0].toString()}),p=postcss.decl({prop:"--ps-page-height",value:r[1].toString()});p.source=t.source,l.append(a),l.append(p),l.append(t.clone())}else if(AREA_CSS_PROPS.some((s=>e.prop.startsWith(s))))if("margin"==e.prop){const e=expandSideDecl(t);for(const[s,o]of SIDES.entries())l.append(t.clone({prop:`--ps-page-margin-${o}`,value:pageMarginValue(e[s],o)}))}else if(e.prop.startsWith("margin-")){const s=e.prop.substr(7);l.append(t.clone({prop:`--ps-page-margin-${s}`,value:pageMarginValue(e.value,s)}))}else if("padding"==e.prop){const s=expandSideDecl(t);for(const[o,r]of SIDES.entries())c.append(t.clone({prop:e.prop+"-"+r,value:pageMarginValue(s[o],r)}))}else if(e.prop.startsWith("padding-")){const s=e.prop.substr(7);c.append(t.clone({prop:e.prop,value:pageMarginValue(e.value,s)}))}else c.append(t.clone());else"width"!=e.prop&&"height"!=e.prop&&l.append(t.clone())}l.nodes.length&&r.insertBefore(e,l),c.nodes.length&&r.insertBefore(e,c);for(const s of e.nodes)if("atrule"==s.type){const o=s,a=o.name.startsWith("footnote");if("-ps-body"==o.name){const s=postcss.rule({selector:`${t} > ps-page-area > [ps-page-body]`});for(;o.first;)s.append(o.first);s.append(postcss.decl({prop:"grid-area",value:"-ps-body"})),r.insertBefore(e,s)}else if("-ps-area"==o.name||a){a&&(o.params=o.name+o.params);const s=o.params.match(/^(.+?)\b(.*)$/);let p=s[1];"footnote"==p&&(p="footnotes");const n=postcss.rule({selector:`${t} > ps-page-area > ps-area[ps-name=${p}]${s[2].trim()}`});for(;o.first;)n.append(o.first);n.append(postcss.decl({prop:"grid-area",value:p})),r.insertBefore(e,n)}else if(o.name.startsWith("-ps-")){const s=o.name.substr(4);if(SIDES.includes(s)){const a=postcss.rule({selector:`${t} > ps-margin[ps-side=${s}]`});for(;o.first;)a.append(o.first);r.insertBefore(e,a)}}else{const s=o.name.substr(0,o.name.indexOf("-")),a=o.name.endsWith("-corner")?`${t} > ps-margin-box[ps-name=${o.name}]`:`${t} > ps-margin[ps-side=${s}] > ps-margin-box[ps-name=${o.name}]`,p=postcss.rule({selector:a});for(p.source=o.source;o.first;)p.append(o.first);for(const s of p.nodes)if("content"==s.prop){const o=postcss.rule({selector:a+"::before"});o.append(s),r.insertBefore(e,o);break}p.nodes.length&&r.insertBefore(e,p)}}}e.remove()}))}function expandSideDecl(e){const s=postcss.list.space(e.value);let o=new Array(4);switch(s.length){case 1:for(let e=0;e<4;e++)o[e]=s[0];break;case 2:o[0]=o[2]=s[0],o[1]=o[3]=s[1];break;case 3:o[0]=s[0],o[1]=o[3]=s[1],o[2]=s[2];break;case 4:o=s}return o}function pageMarginValue(e,s){const o="top"==s||"bottom"==s?"height":"width";return e.endsWith("%")?`calc(var(--ps-page-${o}) * ${parseFloat(e)} / 100)`:e}function getPageSize(e,s){let o=null;const t=postcss.list.space(e),r=t[t.length-1],a="landscape"==r;if(("portrait"==r||a)&&(t.pop(),t.length||t.push("auto")),t.length&&t[0].match(/^[a-z]/i))switch(t[0].toLowerCase()){case"a5":o=["148mm","210mm"];break;case"a4":o=["210mm","297mm"];break;case"a3":o=["297mm","420mm"];break;case"b5":o=["176mm","250mm"];break;case"b4":o=["250mm","353mm"];break;case"jis-b5":o=["182mm","257mm"];break;case"jis-b4":o=["257mm","364mm"];break;case"letter":o=["8.5in","11in"];break;case"legal":o=["8.5in","14in"];break;case"ledger":o=["11in","17in"];break;case"auto":o=s;break;case"a6":o=["105mm","148mm"];break;case"a7":o=["74mm"," 105mm"];break;case"a8":o=["52mm","74mm"];break;case"a9":o=["37mm","52mm"];break;case"a10":o=["26mm","37mm"]}return o||(o=t.length>=2?[t[0],t[1]]:[t[0],t[0]]),a&&(o=[o[1],o[0]]),o}function prefixProps(e,s){e.walkRules((e=>{e.selector=e.selector.replace(PSEUDO_TO_ATTR_RE,"[$1]");const o=prefixPropsDecls(e);if(o.length)if(s.propertiesRegistered)for(const s of o)e.append(s);else{const s=postcss.rule();s.selectors=e.selectors.map((e=>e+"::backdrop")),e.parent.insertBefore(e,s);for(const e of o)s.append(e)}e.nodes.length||e.remove()}))}function prefixPropsDecls(e){const s=[];return e.walkDecls(PROPS_TO_PREFIX_RE,(o=>{let t,r,a=!1;if(o.prop.startsWith("column")&&e.walkDecls(/^-webkit-column/,(e=>{e.remove()})),o.prop.startsWith("page-break-"))PAGE_BREAKS.includes(o.value)?(r=o.clone(),r.prop=o.prop.replace(/^page-break-/,"--ps-break-"),"always"==o.value?r.value="page":"avoid"==o.value&&(r.value="avoid-page"),t=!0):o.remove();else if("position"==o.prop)t=o.value.match(/^running\(/),t||(a=!0);else if("float"==o.prop)"footnote"==o.value?(o.value="-ps-area(footnotes)",t=!0):t=o.value.match(/^-ps-area\(/),t||(a=!0);else if(o.prop.startsWith("footnote-"))o.prop=o.prop.replace("footnote-","-ps-float-"),t=!0;else if("orphans"==o.prop||"widows"==o.prop)o.value.match(/^\d+$/)&&parseInt(o.value)>0?o.prop="--ps-"+o.prop:o.remove();else if("columns"==o.prop||"-ps-columns"==o.prop){const e=o.cloneAfter();e.prop="-ps-column-width";const s=valueParser(o.value).nodes.filter((e=>"word"==e.type)).map((e=>e.value));s[0].match(/^\d+$/)?(o.value=s[0],e.value=s[1]||"auto"):s.length>1&&s[1].match(/^\d+$/)?(o.value=s[1],e.value=s[0]||"auto"):(o.value="auto",e.value="auto"==s[0]?s[1]||"auto":s[0]),o.prop="-ps-column-count",t=!0}else"hyphens"==o.prop?"auto"==o.value&&(o.cloneBefore({value:"manual"}),o.prop="--ps-"+o.prop):"-ps-hyphens"==o.prop?"auto"==o.value&&(o.cloneBefore({prop:"hyphens",value:"manual"}),o.prop="-"+o.prop):"bleed"==o.prop?(o.prop="--ps-bleed",o.cloneBefore({prop:"--ps-bleed-size",value:"auto"==o.value?"0px":o.value})):"marks"==o.prop?o.prop="--ps-"+o.prop:t=!0;(t||a)&&(r||(r=o.clone(),o.prop.startsWith("-ps-")||o.prop.startsWith("-psp-")?r.prop="-"+o.prop:r.prop="--ps-"+o.prop,a&&(r.value="")),s.push(r),a||o.remove())})),s}function replacePseudos(e){e.walkRules((e=>{const s=e.selectors.slice();for(let o=0;o<s.length;o++){const t=s[o].match(FLOAT_PSEUDO_RE);if(t){const[,r,a,p]=t;if("call"==p){let t=`[ps-float-${p}]`;r&&(t=r+" + "+t),"footnote"==a&&(t+='[ps-float-area="footnotes"]'),s[o]=t;const n=e.clone({selector:t+"::before",nodes:[]});e.walkDecls("content",(e=>{const t=valueParser(e.value);for(const e of t.nodes)"function"==e.type&&"counter"==e.value&&(e.value="target-counter",e.nodes.unshift({type:"function",value:"attr",nodes:[HREF_VAL_NODE]},COMMA_VAL_NODE));e.value=t.toString(),o==s.length-1?n.append(e):n.append(e.clone())})),n.nodes.length&&e.parent.insertBefore(e,n)}else{let e="footnote"==a?'[ps-float="footnotes"]':"[ps-float]";s[o]=`${r}${e}[ps-float-display=block]::marker`,s.push(`${r}${e}:not([ps-float-display=block])::before`)}}const r=s[o].match(COLUMNS_PSEUDO_RE);if(r){const[,s,o]=r;e.cloneAfter().selectors=[`${s} > ps-columns > ps-column > ps-column-body${o}`,`${s} > ps-column-body${o}`]}}e.selectors=s}))}function replaceContent(e){e.walkRules(CONTENT_PSEUDOS_RE,(e=>{let s=null,o=!1;if(e.walkDecls("content",(e=>{s=e;const t=valueParser(e.value);for(const e of t.nodes)if("function"==e.type&&GCPM_CONTENT_FUNCS.includes(e.value)){o=!0;break}})),!s)return;const t={},r=e.selectors.slice();for(const s of r){const o=s.match(CONTENT_PSEUDOS_RE),r=o?o[1]:"";let a=t[r];a?a.selector+=", ":(a=t[r]=Object.keys(t).length?e.cloneBefore():e,a.selector=""),a.selector+=s}for(const e in t)if(e){const r=t[e];o?r.walkDecls("content",(s=>{const o=valueParser(s.value),t=o.nodes.findIndex((e=>"function"==e.type&&"leader"==e.value));-1!=t&&replaceLeader(r,s,o,e,t);const a=[];o.walk(((s,o,t)=>{if("function"==s.type&&GCPM_CONTENT_FUNCS.includes(s.value))return t[o]=valueParser(`var(--ps-${e}-val-${a.length}, "")`).nodes[0],a.push(s),!1})),s.value=o.toString(),r.insertAfter(s,s.clone({prop:`--ps-${e}-vals`,value:a.map((e=>valueParser.stringify(e))).join(" ")}))})):r.append(s.clone({prop:`--ps-${e}-vals`,value:"none"}))}}))}function replaceLeader(e,s,o,t,r){const a=e.selectors.map((e=>`${e.substring(0,e.indexOf("::"+t))} > ps-leader[ps-position=${t}]`)).join(", ");e.cloneAfter({selector:a}).walkDecls("content",(e=>e.remove()))}function load(e){return new Promise(((s,o)=>{const t=new XMLHttpRequest;t.open("GET",e),t.onload=()=>s(t.responseText),t.onerror=()=>o(new Error(`Unable to fetch '${e}'`)),t.send()}))}exports.default=postcss.plugin("ps-precss",(e=>{let s=Object.assign(Object.create(defaultOptions),e);return e=>(s.mediaType&&selectMediaType(e,s),css3Pseudos(e),replaceAtPageRules(e,s),prefixProps(e,s),replacePseudos(e),replaceContent(e),e)})),exports.styleAttrPlugin=postcss.plugin("ps-precss-styleattr",(()=>e=>{const s=prefixPropsDecls(e);for(const o of s)e.append(o)})),exports.replaceMediaType=replaceMediaType,exports.importUnfold=postcss.plugin("ps-import-unfold",(e=>s=>{const o=[];return s.walkAtRules("import",(s=>{const t=valueParser(s.params).nodes[0];var r;if("string"==t.type?r=new URL(t.value,e.from):"function"==t.type&&"url"==t.value&&t.nodes.length&&(r=new URL(t.nodes[0].value,e.from)),r){const t=Object.create(e);t.from=r.href;const a=load(r.href).then((e=>postcss().use(exports.importUnfold(t)).process(e,t))).then((e=>{s.append(e.root.nodes)})).catch((e=>{util_1.logger.warn(e)}));o.push(a)}})),s.walkDecls(URI_PROPS_RE,(s=>{const o=valueParser(s.value);o.walk((s=>{if("function"==s.type&&s.value,"function"==s.type&&"url"==s.value){const o=s.nodes[0];"word"==o.type&&Object.assign(o,{type:"string",quote:'"'});const t=new URL(o.value,e.from);o.value=t.href}})),s.value=o.toString()})),Promise.all(o)})),exports.importFold=postcss.plugin("ps-import-fold",(()=>function e(s){s.walkAtRules("import",(s=>{if(s.nodes){e(s);const o=postcss.list.space(s.params),t=postcss.root();t.nodes=s.nodes,delete s.nodes;const r=new Blob([t.toString()],{type:"text/css"});o[0]=`url(${URL.createObjectURL(r)})`,s.params=o.join(" ")}}))}));

},{"./util":3,"postcss":undefined,"postcss-value-parser":undefined}],3:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.walk=exports.ranges=exports.rects=exports.events=exports.debug=exports.io=exports.str=exports.dom=exports.logger=exports.log=void 0;const ranges_1=require("./util/ranges"),rects_1=require("./util/rects"),cssesc=require("cssesc");var log,dom,str,io,debug,events;!function(e){let t;!function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.info=2]="info",e[e.debug=3]="debug"}(t=e.LogLevel||(e.LogLevel={}));e.Logger=class{constructor(){this._scopes=[],this._level=t.warn}debug(e,o){this.log(t.debug,e,o)}info(e,o){this.log(t.info,e,o)}warn(e,o){this.log(t.warn,e,o)}error(e,o){this.log(t.error,e,o)}levelFromString(e){return"error"==e?0:"warn"==e?1:"info"==e?2:"debug"==e?3:void 0}setLevel(e){this._level="string"==typeof e?this.levelFromString(e):e}setReporter(e){this._reporter=e}addScope(e){this._scopes.push(e)}removeScope(e=1){for(let t=0;t<e;t++)this._scopes.pop()}log(e,t,o){if(e>this._level||!this._reporter)return;const r={level:e,message:"function"==typeof t?t():t};o&&this._scopes.push(o),this._scopes.length&&(r.scopes=this._scopes.map((e=>"string"==typeof e?e:e()))),this._reporter.log(r),o&&this._scopes.pop()}},e.defaultReporter={log:function(e){let o=e.message;e.scopes&&(o+=` (${e.scopes.join(", ")})`),e.level==t.error?console.error(o):e.level==t.warn?console.warn(o):e.level==t.info?console.info(o):e.level==t.debug&&console.debug(o)}}}(log=exports.log||(exports.log={})),exports.logger=new log.Logger,exports.logger.setReporter(log.defaultReporter),function(e){let t=0;e.id=function(e){return e?e.id||(e.id="ps-"+t++):"ps-"+t++},e.docInteractive=function(e=document){return new Promise(((t,o)=>{"loading"!=e.readyState?t():e.addEventListener("DOMContentLoaded",(()=>t()))}))},e.docComplete=function(e=document){return new Promise(((t,o)=>{"complete"==e.readyState?t():(e.defaultView.addEventListener("load",(()=>t())),e.defaultView.addEventListener("error",o))}))},e.isElement=function(e){return e&&e.nodeType==Node.ELEMENT_NODE}}(dom=exports.dom||(exports.dom={})),function(e){function t(e){return"-"+e.toLowerCase()}function o(e){const t=e.toLowerCase();let o="",r=!1;for(let e=0;e<6&&void 0!==t[e];e++){const n=t.charCodeAt(e);if(r=32===n,!(n>=97&&n<=102||n>=48&&n<=57))break;o+=t[e]}if(0===o.length)return;const n=parseInt(o,16);return n>=55296&&n<=57343||0===n||n>1114111?["\ufffd",o.length+(r?1:0)]:[String.fromCodePoint(n),o.length+(r?1:0)]}e.decamelize=function(e){return e.replace(/[A-Z]/g,t)},e.cssEscape=function(e){return cssesc(e,{quotes:"double"})};const r=/\\/;e.cssUnescape=function(e){if(!r.test(e))return e;let t="";for(let r=0;r<e.length;r++)if("\\"!==e[r])t+=e[r];else{const n=o(e.slice(r+1,r+7));if(void 0!==n){t+=n[0],r+=n[1];continue}if("\\"===e[r+1]){t+="\\",r++;continue}e.length===r+1&&(t+=e[r])}return t}}(str=exports.str||(exports.str={})),function(e){e.parseOptionsFromElement=function(e,t){const o={};e.hasAttribute("ps-options")&&Object.assign(o,JSON.parse(e.getAttribute("ps-options")));for(const r in t){const n=Array.isArray(t[r])?"array":typeof t[r],s=e.getAttribute("ps-"+str.decamelize(r));null!==s&&("boolean"==n?o[r]="true"==s:"array"==n?o[r]=s.length?s.trim().split(" "):null:"object"==n?o[r]=JSON.parse(s):"string"==n?o[r]=s:"number"==n&&(o[r]=parseFloat(s)))}return o},e.mergeOptions=function e(t,...o){const r=o.shift();if(r)for(const o of Object.keys(r))r[o]&&"object"==typeof r[o]&&!Array.isArray(r[o])?t.hasOwnProperty(o)&&"object"==typeof t[o]&&!Array.isArray(t[o])?e(t[o],r[o]):t[o]=Object.assign({},r[o]):t[o]=r[o];return o.length?e(t,...o):t},e.load=function(e){return new Promise(((t,o)=>{const r=new XMLHttpRequest;r.open("GET",e),r.onload=()=>t(r.responseText),r.onerror=()=>o(new Error("Unable to fetch '"+e+"'")),r.send()}))},e.loadScript=function(e){return new Promise(((t,o)=>{const r=document.createElement("script");r.src=e,r.addEventListener("error",(()=>{o(new Error(`Unable to load the script '${e}'.`))})),r.addEventListener("load",t),document.head.appendChild(r)}))}}(io=exports.io||(exports.io={})),function(e){function t(e,t=document){const r=t.defaultView;o({top:e.top+r.scrollY,bottom:e.bottom+r.scrollY,left:e.left+r.scrollX,right:e.right+r.scrollX},t)}function o(e,t=document){const o=document.createElement("div");o.style.position="absolute",o.style.border="1px solid red",o.style.margin=o.style.padding="0",o.style.top=e.top+"px",o.style.left=e.left+"px",o.style.width=e.right-e.left-2+"px",o.style.height=e.bottom-e.top-2+"px",t.documentElement.appendChild(o)}e.drawClientRects=function(e,o=document){for(let r=0;r!=e.length;r++){t(e[r],o)}},e.drawClientRect=t,e.drawScrollRect=o,e.drawPoint=function(e){const t=e.container.ownerDocument.defaultView;let o;if(dom.isElement(e.container)){const r=ranges_1.default.nodeAtPoint(e);if(r)if(dom.isElement(r))o=rects_1.default.boundingScrollRect(r).top;else{const e=document.createRange();e.selectNode(r),o=rects_1.default.scrollRect(e.getBoundingClientRect(),t).top}else o=rects_1.default.boundingScrollRect(e.container).bottom}else{const r=document.createRange();r.setStartBefore(e.container),r.setEnd(e.container,e.offset),o=rects_1.default.scrollRect(r.getBoundingClientRect(),t).bottom}const r=document.createElement("div");r.style.position="absolute",r.style.background="red",r.style.height="1px",r.style.left="0",r.style.width="100%",r.style.top=o+"px",document.documentElement.appendChild(r)},e.logCaretPositionOnClick=function(e){e||(e=document),e.addEventListener("click",(t=>{const o=e.caretRangeFromPoint(t.clientX,t.y);console.log(o.startContainer,o.startOffset)}))}}(debug=exports.debug||(exports.debug={})),function(e){e.EventEmitter=class{constructor(){this.on=this.addListener}addListener(e,t){this.listeners||(this.listeners=Object.create(null));let o=this.listeners[e];return o||(o=[],this.listeners[e]=o),o.push(t),this}removeListener(e,t){const o=this.listeners&&this.listeners[e];return o&&o.splice(o.indexOf(t),1),this}listenerCount(e){const t=this.listeners&&this.listeners[e];return t?t.length:0}emit(e,t){const o="string"==typeof e?{type:e}:e,r=this.listeners&&this.listeners[o.type];if(r&&r.length)for(const e of r){const r=e.call(this,o,t);if(void 0!==r)return r}}}}(events=exports.events||(exports.events={}));var rects_2=require("./util/rects");Object.defineProperty(exports,"rects",{enumerable:!0,get:function(){return rects_2.default}});var ranges_2=require("./util/ranges");Object.defineProperty(exports,"ranges",{enumerable:!0,get:function(){return ranges_2.default}});var walk_1=require("./util/walk");Object.defineProperty(exports,"walk",{enumerable:!0,get:function(){return walk_1.default}});

},{"./util/ranges":4,"./util/rects":5,"./util/walk":6,"cssesc":undefined}],4:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const walk_1=require("./walk");var ranges;!function(t){function n(t){return{container:t.startContainer,offset:t.startOffset}}function e(t){return{container:t.endContainer,offset:t.endOffset}}function o(t){return t.startContainer.nodeType==Node.ELEMENT_NODE?t.startContainer.childNodes[t.startOffset]:null}function r(t){return t.endContainer.nodeType==Node.ELEMENT_NODE?t.endContainer.childNodes[t.endOffset-1]:null}function i(t){const n=t.ownerDocument.createRange();return n.selectNodeContents(t),n.extractContents()}t.isRange=function(t){return t&&t.constructor==Range},t.isPoint=function(t){return t&&"container"in t&&"offset"in t},t.clonePoint=function(t){return{container:t.container,offset:t.offset}},t.pointEquals=function(t,n){return t.container==n.container&&t.offset==n.offset},t.breakRangeBefore=function(t,n){const e=n.ownerDocument.createRange();return e.setStart(t.startContainer,t.startOffset),e.setEndBefore(n),t.setStartBefore(n),e},t.breakRangeAfter=function(t,n){const e=n.ownerDocument.createRange();return e.setStart(t.startContainer,t.startOffset),e.setEndAfter(n),t.setStartAfter(n),e},t.positionBefore=function(t){const e=t.ownerDocument.createRange();return e.setStartBefore(t),n(e)},t.positionAfter=function(t){const n=t.ownerDocument.createRange();return n.setEndAfter(t),e(n)},t.positionAtStart=function(t){return{container:t,offset:0}},t.positionAtEnd=function(t){return{container:t,offset:t.childNodes.length}},t.rangeStart=n,t.rangeEnd=e,t.startNode=o,t.endNode=r,t.staticStartNode=function(t){const n=o(t);return walk_1.default.isStaticNode(n)?n:walk_1.default.next(n,walk_1.default.isStaticNode)},t.staticEndNode=function(t){const n=r(t);return walk_1.default.isStaticNode(n)?n:walk_1.default.previous(n,walk_1.default.isStaticNode)},t.nodeAtPoint=function(t){return t.container.nodeType==Node.TEXT_NODE?t.container:t.container.childNodes.item(t.offset)},t.containsPoint=function(t,n){return(t.endContainer!=n.container||t.endOffset!=n.offset)&&t.isPointInRange(n.container,n.offset)},t.isPrecedingPoint=function(t,n){if(n.container==t.container)return n.offset<t.offset;{const e=new Range;return e.setStart(n.container,n.offset),e.setEnd(t.container,t.offset),!e.collapsed}},t.textPositionFromPoint=function(t,n,e){t.defaultView.scrollTo(n,e);const o=t.caretRangeFromPoint(n-t.defaultView.scrollX,e-t.defaultView.scrollY);return o?{container:o.startContainer,offset:o.startOffset}:null},t.findPointInRanges=function(n,e,o=!1){let r;if(o){for(let o=n.length-1;o>=0;o--)if(r=n[o],t.containsPoint(r,e))return o}else for(let o=0;o<n.length;o++)if(r=n[o],t.containsPoint(r,e))return o;return-1},t.extractNodeContents=i,t.appendNodeContents=function(t,n){n.appendChild(i(t))}}(ranges||(ranges={})),exports.default=ranges;

},{"./walk":6}],5:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const ranges_1=require("./ranges");var rects;!function(t){function o(t,o){return{top:t.top+o.scrollY,bottom:t.bottom+o.scrollY,left:t.left+o.scrollX,right:t.right+o.scrollX,width:t.width,height:t.height}}t.boundingScrollRect=function(t){return ranges_1.default.isRange(t)?o(t.getBoundingClientRect(),t.commonAncestorContainer.ownerDocument.defaultView):o(t.getBoundingClientRect(),t.ownerDocument.defaultView)},t.scrollRect=o,t.rectsLines=function(t,o){const e=[];let r=null;for(const o of t)o.left!=o.right&&(!r||o.bottom>r.bottom&&o.top>r.top&&o.left<=r.left?(r={left:o.left,bottom:o.bottom,right:o.right,top:o.top},e.push(r)):(o.top<r.top&&(r.top=o.top),o.bottom>r.bottom&&(r.bottom=o.bottom),o.right>r.right&&(r.right=o.right)));for(const t of e)t.top+=o.scrollY,t.bottom+=o.scrollY,t.left+=o.scrollX,t.right+=o.scrollX;return e},t.equalRects=function(t,o){return t.top!=o.top||t.right!=o.right||t.bottom!=o.bottom||t.left!=o.left},t.includesRect=function(t,o){return o.top>=t.top&&o.bottom<=t.bottom&&o.left>=t.left&&o.right<=t.right},t.contentSizingHeight=function(t,o){return o-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)-parseFloat(t.borderTopWidth)-parseFloat(t.borderBottomWidth)}}(rects||(rects={})),exports.default=rects;

},{"./ranges":4}],6:[function(require,module,exports){
"use strict";var walk;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){function t(e){return e&&e.nodeType==Node.ELEMENT_NODE}function n(e){return t(e)&&"innerText"in e}function i(e){return t(e)&&"ownerSVGElement"in e}function r(e){return i(e)&&null==e.ownerSVGElement}function l(e){return e&&e.nodeType==Node.TEXT_NODE}function o(e){return"none"!=e.display&&"table-column-group"!=e.display&&("static"==e.position||"relative"==e.position)}function u(e){return l(e)?0!=e.nodeValue.trim().length:!!t(e)&&o(getComputedStyle(e))}function s(e){return"none"!=e.float||!(e.display.startsWith("inline")||e.display.startsWith("ruby")||e.display.startsWith("table-column"))}e.createWalker=function(e,t,n){return e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ALL,{acceptNode:e=>!t||t(e)?NodeFilter.FILTER_ACCEPT:n&&n(e)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_REJECT})},e.createIterator=function(e,t,n){return e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_ALL,{acceptNode:e=>!t||t(e)?NodeFilter.FILTER_ACCEPT:n&&n(e)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_REJECT})},e.firstChild=function(e,t){let n=e?e.firstChild:null;for(;n;){if(t(n))return n;n=n.nextSibling}return null},e.lastChild=function(e,t){let n=e?e.lastChild:null;for(;n;){if(t(n))return n;n=n.previousSibling}return null},e.nextSibling=function(e,t){let n=e?e.nextSibling:null;for(;n;){if(t(n))return n;n=n.nextSibling}return null},e.previousSibling=function(e,t){let n=e?e.previousSibling:null;for(;n;){if(t(n))return n;n=n.previousSibling}return null},e.ancestor=function(e,t,n){let i=e.parentNode;for(;i&&i!==n;){if(t(i))return i;i=i.parentNode}return null},e.ancestorOrSelf=function(e,t,n){let i=e;for(;i&&i!==n;){if(t(i))return i;i=i.parentNode}return null},e.next=function e(t,n,i){let r=t.firstChild;if(r)return n(r)?r:e(r,n,i);if(t===i)return null;for(;!(r=t.nextSibling);)if((t=t.parentNode)===i)return null;return n(r)?r:e(r,n,i)},e.previous=function e(t,n,i){if(t===i)return null;let r=t.previousSibling;if(r){let t=r.lastChild;for(;t;)r=t,t=t.lastChild;return n(r)?r:e(r,n,i)}return r=t.parentNode,r===i?null:n(r)?r:e(r,n,i)},e.all=function(e,t,n,i){const r=[];let l=t;for(;l=e(l,n,i);)r.push(l);return r},e.isNode=function(e){return!0},e.isElement=t,e.isHTMLElement=n,e.isSVGElement=i,e.isSVGRootSVGElement=r,e.isHTMLOrSVGRootSVGElement=function(e){return n(e)||r(e)},e.isText=l,e.isConstructedBy=function(e){return function(t){return t.constructor==e}},e.isInstanceOf=function(e){return function(t){return t instanceof e}},e.isStaticStyle=o,e.isStatic=u,e.isRow=function(e){return"table-row"==e.display?"table-row":!("flex"!=e.display||!e.flexDirection.startsWith("row"))&&"flex-row"},e.predicate=function(e,...t){return n=>!(e&&!e(n))&&t.every((e=>e(n)))},e.displayAsBlockStyle=s,e.displayAsBlock=function(e){return!l(e)&&(t(e)?s(getComputedStyle(e)):void 0)},e.displayAsInlineBlock=function(e){if(l(e))return!1;if(t(e)){const t=getComputedStyle(e);return t.display.startsWith("inline-")||"inline"==t.display&&e instanceof SVGElement}},e.isDisplayed=function(e){return"none"!=getComputedStyle(e).display},e.hasSize=function(e){return 0!=e.clientWidth||0!=e.clientHeight},e.isBreakedAfter=function(e){return e.hasAttribute("ps-breaked-after")},e.isStaticNode=u,e.isStaticElement=e.predicate(e.isElement,e.isStatic),e.isStaticHtmlElement=e.predicate(e.isHTMLElement,e.isStatic),e.isStaticHtmlBlock=e.predicate(e.isHTMLElement,e.isStatic,e.displayAsBlock),e.isBlockElement=e.predicate(e.isElement,e.displayAsBlock),e.isInlineBlockElement=e.predicate(e.isElement,e.displayAsInlineBlock)}(walk||(walk={})),exports.default=walk;

},{}]},{},[1])(1)
});
