@well-played.gg/react-sdk 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(Je,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("react"),require("@well-played.gg/typescript-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@well-played.gg/typescript-sdk","react-dom"],K):(Je=typeof globalThis<"u"?globalThis:Je||self,K(Je.WellPlayedReactSDK={},Je.React,Je.typescriptSdk,Je.ReactDOM))})(this,function(Je,K,Pr,gy){"use strict";function yy(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in n)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var nl=function(n,e){return nl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},nl(n,e)};function bu(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");nl(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var xe=function(){return xe=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},xe.apply(this,arguments)};function vu(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function Rr(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var rl="Invariant Violation",wu=Object.setPrototypeOf,_y=wu===void 0?function(n,e){return n.__proto__=e,n}:wu,by=function(n){bu(e,n);function e(t){t===void 0&&(t=rl);var r=n.call(this,typeof t=="number"?rl+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return r.framesToPop=1,r.name=rl,_y(r,e.prototype),r}return e}(Error);function sr(n,e){if(!n)throw new by(e)}var Su=["debug","log","warn","error","silent"],vy=Su.indexOf("log");function hs(n){return function(){if(Su.indexOf(n)>=vy){var e=console[n]||console.log;return e.apply(console,arguments)}}}(function(n){n.debug=hs("debug"),n.log=hs("log"),n.warn=hs("warn"),n.error=hs("error")})(sr||(sr={}));var ku="3.13.5";function hn(n){try{return n()}catch{}}const il=hn(function(){return globalThis})||hn(function(){return window})||hn(function(){return self})||hn(function(){return global})||hn(function(){return hn.constructor("return this")()});var xu=new Map;function wy(n){var e=xu.get(n)||1;return xu.set(n,e+1),"".concat(n,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function Sy(n,e){var t=wy("stringifyForDisplay");return JSON.stringify(n,function(r,i){return i===void 0?t:i},e).split(JSON.stringify(t)).join("<undefined>")}function ps(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(typeof e=="number"){var i=e;e=Ou(i),e||(e=Au(i,t),t=[])}n.apply(void 0,[e].concat(t))}}var nn=Object.assign(function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];e||sr(e,Ou(t,r)||Au(t,r))},{debug:ps(sr.debug),log:ps(sr.log),warn:ps(sr.warn),error:ps(sr.error)}),Eu=Symbol.for("ApolloErrorMessageHandler_"+ku);function Tu(n){if(typeof n=="string")return n;try{return Sy(n,2).slice(0,1e3)}catch{return"<non-serializable>"}}function Ou(n,e){if(e===void 0&&(e=[]),!!n)return il[Eu]&&il[Eu](n,e.map(Tu))}function Au(n,e){if(e===void 0&&(e=[]),!!n)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:ku,message:n,args:e.map(Tu)})))}var ky=hn(function(){return navigator.product})=="ReactNative",xy=typeof Symbol=="function"&&typeof Symbol.for=="function",Cu=typeof hn(function(){return window.document.createElement})=="function",Ey=hn(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1,Ty=(Cu||ky)&&!Ey;function sl(n){return n!==null&&typeof n=="object"}function ol(){}const Oy=ol,Ay=typeof WeakRef<"u"?WeakRef:function(n){return{deref:()=>n}},Cy=typeof WeakMap<"u"?WeakMap:Map,My=typeof FinalizationRegistry<"u"?FinalizationRegistry:function(){return{register:ol,unregister:ol}},Ny=10024;class Mu{constructor(e=1/0,t=Oy){this.max=e,this.dispose=t,this.map=new Cy,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const r=this.unfinalizedNodes.values();for(let i=0;i<Ny;i++){const s=r.next().value;if(!s)break;this.unfinalizedNodes.delete(s);const l=s.key;delete s.key,s.keyRef=new Ay(l),this.registry.register(l,s,s)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new My(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.scheduleFinalization(r),this.map.set(e,r),this.size++,r.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return t?(this.deleteNode(t),!0):!1}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}var ll=new WeakSet;function Iy(n){n.size<=(n.max||-1)||ll.has(n)||(ll.add(n),setTimeout(function(){n.clean(),ll.delete(n)},100))}var Py=function(n,e){var t=new Mu(n,e);return t.set=function(r,i){var s=Mu.prototype.set.call(this,r,i);return Iy(this),s},t},Ry=Symbol.for("apollo.cacheSize"),Dy=xe({},il[Ry]);function Nu(n){return Array.isArray(n)&&n.length>0}function Ly(n){var e=new Set([n]);return e.forEach(function(t){sl(t)&&By(t)===t&&Object.getOwnPropertyNames(t).forEach(function(r){sl(t[r])&&e.add(t[r])})}),n}function By(n){if(globalThis.__DEV__!==!1&&!Object.isFrozen(n))try{Object.freeze(n)}catch(e){if(e instanceof TypeError)return null;throw e}return n}function Iu(n){return globalThis.__DEV__!==!1&&Ly(n),n}function al(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Object.create(null);return n.forEach(function(r){r&&Object.keys(r).forEach(function(i){var s=r[i];s!==void 0&&(t[i]=s)})}),t}function cl(n,e){return al(n,e,e.variables&&{variables:al(xe(xe({},n&&n.variables),e.variables))})}var Fy=function(n){var e=Rr(Rr(Rr([],n.graphQLErrors,!0),n.clientErrors,!0),n.protocolErrors,!0);return n.networkError&&e.push(n.networkError),e.map(function(t){return sl(t)&&t.message||"Error message not found."}).join(`
2
- `)},Pu=function(n){bu(e,n);function e(t){var r=t.graphQLErrors,i=t.protocolErrors,s=t.clientErrors,l=t.networkError,c=t.errorMessage,u=t.extraInfo,d=n.call(this,c)||this;return d.name="ApolloError",d.graphQLErrors=r||[],d.protocolErrors=i||[],d.clientErrors=s||[],d.networkError=l||null,d.message=c||Fy(d),d.extraInfo=u,d.cause=Rr(Rr(Rr([l],r||[],!0),i||[],!0),s||[],!0).find(function(h){return!!h})||null,d.__proto__=e.prototype,d}return e}(Error);const{toString:Ru,hasOwnProperty:zy}=Object.prototype,Du=Function.prototype.toString,ul=new Map;function fl(n,e){try{return dl(n,e)}finally{ul.clear()}}function dl(n,e){if(n===e)return!0;const t=Ru.call(n),r=Ru.call(e);if(t!==r)return!1;switch(t){case"[object Array]":if(n.length!==e.length)return!1;case"[object Object]":{if(Bu(n,e))return!0;const i=Lu(n),s=Lu(e),l=i.length;if(l!==s.length)return!1;for(let c=0;c<l;++c)if(!zy.call(e,i[c]))return!1;for(let c=0;c<l;++c){const u=i[c];if(!dl(n[u],e[u]))return!1}return!0}case"[object Error]":return n.name===e.name&&n.message===e.message;case"[object Number]":if(n!==n)return e!==e;case"[object Boolean]":case"[object Date]":return+n==+e;case"[object RegExp]":case"[object String]":return n==`${e}`;case"[object Map]":case"[object Set]":{if(n.size!==e.size)return!1;if(Bu(n,e))return!0;const i=n.entries(),s=t==="[object Map]";for(;;){const l=i.next();if(l.done)break;const[c,u]=l.value;if(!e.has(c)||s&&!dl(u,e.get(c)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":n=new Uint8Array(n),e=new Uint8Array(e);case"[object DataView]":{let i=n.byteLength;if(i===e.byteLength)for(;i--&&n[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const i=Du.call(n);return i!==Du.call(e)?!1:!Vy(i,$y)}}return!1}function Lu(n){return Object.keys(n).filter(Wy,n)}function Wy(n){return this[n]!==void 0}const $y="{ [native code] }";function Vy(n,e){const t=n.length-e.length;return t>=0&&n.indexOf(e,t)===t}function Bu(n,e){let t=ul.get(n);if(t){if(t.has(e))return!0}else ul.set(n,t=new Set);return t.add(e),!1}var or;(function(n){n[n.loading=1]="loading",n[n.setVariables=2]="setVariables",n[n.fetchMore=3]="fetchMore",n[n.refetch=4]="refetch",n[n.poll=6]="poll",n[n.ready=7]="ready",n[n.error=8]="error"})(or||(or={}));var mi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fu={exports:{}};(function(n){n.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=void 0,n.exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,n.exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,Object.assign(n.exports,K)})(Fu);var ge=Fu.exports;const zu=yy({__proto__:null,default:Hy(ge)},[ge]);var Wu=xy?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function hl(){nn("createContext"in zu,54);var n=ge.createContext[Wu];return n||(Object.defineProperty(ge.createContext,Wu,{value:n=ge.createContext({}),enumerable:!1,writable:!1,configurable:!0}),n.displayName="ApolloContext"),n}var Uy=function(n){var e=n.client,t=n.children,r=hl(),i=ge.useContext(r),s=ge.useMemo(function(){return xe(xe({},i),{client:e||i.client})},[i,e]);return nn(s.client,55),ge.createElement(r.Provider,{value:s},t)};function $u(n){var e=ge.useContext(hl()),t=n||e.client;return nn(!!t,58),t}var Vu=!1,Ky="useSyncExternalStore",jy=zu[Ky],qy=jy||function(n,e,t){var r=e();globalThis.__DEV__!==!1&&!Vu&&r!==e()&&(Vu=!0,globalThis.__DEV__!==!1&&nn.error(68));var i=ge.useState({inst:{value:r,getSnapshot:e}}),s=i[0].inst,l=i[1];return Ty?ge.useLayoutEffect(function(){Object.assign(s,{value:r,getSnapshot:e}),pl(s)&&l({inst:s})},[n,r,e]):Object.assign(s,{value:r,getSnapshot:e}),ge.useEffect(function(){return pl(s)&&l({inst:s}),n(function(){pl(s)&&l({inst:s})})},[n]),r};function pl(n){var e=n.value,t=n.getSnapshot;try{return e!==t()}catch{return!0}}var pn;(function(n){n[n.Query=0]="Query",n[n.Mutation=1]="Mutation",n[n.Subscription=2]="Subscription"})(pn||(pn={}));var gi;function Hu(n){var e;switch(n){case pn.Query:e="Query";break;case pn.Mutation:e="Mutation";break;case pn.Subscription:e="Subscription";break}return e}function Uu(n){gi||(gi=new Py(Dy.parser||1e3));var e=gi.get(n);if(e)return e;var t,r,i;nn(!!n&&!!n.kind,70,n);for(var s=[],l=[],c=[],u=[],d=0,h=n.definitions;d<h.length;d++){var p=h[d];if(p.kind==="FragmentDefinition"){s.push(p);continue}if(p.kind==="OperationDefinition")switch(p.operation){case"query":l.push(p);break;case"mutation":c.push(p);break;case"subscription":u.push(p);break}}nn(!s.length||l.length||c.length||u.length,71),nn(l.length+c.length+u.length<=1,72,n,l.length,u.length,c.length),r=l.length?pn.Query:pn.Mutation,!l.length&&!c.length&&(r=pn.Subscription);var y=l.length?l:c.length?c:u;nn(y.length===1,73,n,y.length);var g=y[0];t=g.variableDefinitions||[],g.name&&g.name.kind==="Name"?i=g.name.value:i="data";var _={name:i,type:r,variables:t};return gi.set(n,_),_}Uu.resetCache=function(){gi=void 0};function Jy(n,e){var t=Uu(n),r=Hu(e),i=Hu(t.type);nn(t.type===e,74,r,r,i)}var Gy=Cu?ge.useLayoutEffect:ge.useEffect,Yy=Symbol.for("apollo.hook.wrappers");function Qy(n,e,t){var r=t.queryManager,i=r&&r[Yy],s=i&&i[n];return s?s(e):e}var Xy=Object.prototype.hasOwnProperty;function Ku(){}var ms=Symbol();function ml(n,e){return e===void 0&&(e=Object.create(null)),Qy("useQuery",Zy,$u(e&&e.client))(n,e)}function Zy(n,e){var t=ju(n,e),r=t.result,i=t.obsQueryFields;return ge.useMemo(function(){return xe(xe({},r),i)},[r,i])}function e0(n,e,t,r,i){function s(p){var y;Jy(e,pn.Query);var g={client:n,query:e,observable:r&&r.getSSRObservable(i())||n.watchQuery(gl(void 0,n,t,i())),resultData:{previousData:(y=p==null?void 0:p.resultData.current)===null||y===void 0?void 0:y.data}};return g}var l=ge.useState(s),c=l[0],u=l[1];function d(p){var y,g;Object.assign(c.observable,(y={},y[ms]=p,y));var _=c.resultData;u(xe(xe({},c),{query:p.query,resultData:Object.assign(_,{previousData:((g=_.current)===null||g===void 0?void 0:g.data)||_.previousData,current:void 0})}))}if(n!==c.client||e!==c.query){var h=s(c);return u(h),[h,d]}return[c,d]}function ju(n,e){var t=$u(e.client),r=ge.useContext(hl()).renderPromises,i=!!r,s=t.disableNetworkFetches,l=e.ssr!==!1&&!e.skip,c=e.partialRefetch,u=qu(t,n,e,i),d=e0(t,n,e,r,u),h=d[0],p=h.observable,y=h.resultData,g=d[1],_=u(p);r0(y,p,t,e,_);var S=ge.useMemo(function(){return l0(p)},[p]);n0(p,r,l);var k=t0(y,p,t,e,_,s,c,i,{onCompleted:e.onCompleted||Ku,onError:e.onError||Ku});return{result:k,obsQueryFields:S,observable:p,resultData:y,client:t,onQueryExecuted:g}}function t0(n,e,t,r,i,s,l,c,u){var d=ge.useRef(u);ge.useEffect(function(){d.current=u});var h=(c||s)&&r.ssr===!1&&!r.skip?Gu:r.skip||i.fetchPolicy==="standby"?Yu:void 0,p=n.previousData,y=ge.useMemo(function(){return h&&gs(h,p,e,t)},[t,e,h,p]);return qy(ge.useCallback(function(g){if(c)return function(){};var _=function(){var A=n.current,P=e.getCurrentResult();A&&A.loading===P.loading&&A.networkStatus===P.networkStatus&&fl(A.data,P.data)||yl(P,n,e,t,l,g,d.current)},S=function(A){if(k.current.unsubscribe(),k.current=e.resubscribeAfterError(_,S),!Xy.call(A,"graphQLErrors"))throw A;var P=n.current;(!P||P&&P.loading||!fl(A,P.error))&&yl({data:P&&P.data,error:A,loading:!1,networkStatus:or.error},n,e,t,l,g,d.current)},k={current:e.subscribe(_,S)};return function(){setTimeout(function(){return k.current.unsubscribe()})}},[s,c,e,n,l,t]),function(){return y||Ju(n,e,d.current,l,t)},function(){return y||Ju(n,e,d.current,l,t)})}function n0(n,e,t){e&&t&&(e.registerSSRObservable(n),n.getCurrentResult().loading&&e.addObservableQueryPromise(n))}function r0(n,e,t,r,i){var s;e[ms]&&!fl(e[ms],i)&&(e.reobserve(gl(e,t,r,i)),n.previousData=((s=n.current)===null||s===void 0?void 0:s.data)||n.previousData,n.current=void 0),e[ms]=i}function qu(n,e,t,r){t===void 0&&(t={});var i=t.skip;t.ssr,t.onCompleted,t.onError;var s=t.defaultOptions,l=vu(t,["skip","ssr","onCompleted","onError","defaultOptions"]);return function(c){var u=Object.assign(l,{query:e});return r&&(u.fetchPolicy==="network-only"||u.fetchPolicy==="cache-and-network")&&(u.fetchPolicy="cache-first"),u.variables||(u.variables={}),i?(u.initialFetchPolicy=u.initialFetchPolicy||u.fetchPolicy||_l(s,n.defaultOptions),u.fetchPolicy="standby"):u.fetchPolicy||(u.fetchPolicy=(c==null?void 0:c.options.initialFetchPolicy)||_l(s,n.defaultOptions)),u}}function gl(n,e,t,r){var i=[],s=e.defaultOptions.watchQuery;return s&&i.push(s),t.defaultOptions&&i.push(t.defaultOptions),i.push(al(n&&n.options,r)),i.reduce(cl)}function yl(n,e,t,r,i,s,l){var c=e.current;c&&c.data&&(e.previousData=c.data),!n.error&&Nu(n.errors)&&(n.error=new Pu({graphQLErrors:n.errors})),e.current=gs(o0(n,t,i),e.previousData,t,r),s(),i0(n,c==null?void 0:c.networkStatus,l)}function i0(n,e,t){if(!n.loading){var r=s0(n);Promise.resolve().then(function(){r?t.onError(r):n.data&&e!==n.networkStatus&&n.networkStatus===or.ready&&t.onCompleted(n.data)}).catch(function(i){globalThis.__DEV__!==!1&&nn.warn(i)})}}function Ju(n,e,t,r,i){return n.current||yl(e.getCurrentResult(),n,e,i,r,function(){},t),n.current}function _l(n,e){var t;return(n==null?void 0:n.fetchPolicy)||((t=e==null?void 0:e.watchQuery)===null||t===void 0?void 0:t.fetchPolicy)||"cache-first"}function s0(n){return Nu(n.errors)?new Pu({graphQLErrors:n.errors}):n.error}function gs(n,e,t,r){var i=n.data;n.partial;var s=vu(n,["data","partial"]),l=xe(xe({data:i},s),{client:r,observable:t,variables:t.variables,called:n!==Gu&&n!==Yu,previousData:e});return l}function o0(n,e,t){return n.partial&&t&&!n.loading&&(!n.data||Object.keys(n.data).length===0)&&e.options.fetchPolicy!=="cache-only"?(e.refetch(),xe(xe({},n),{loading:!0,networkStatus:or.refetch})):n}var Gu=Iu({loading:!0,data:void 0,error:void 0,networkStatus:or.loading}),Yu=Iu({loading:!1,data:void 0,error:void 0,networkStatus:or.ready});function l0(n){return{refetch:n.refetch.bind(n),reobserve:n.reobserve.bind(n),fetchMore:n.fetchMore.bind(n),updateQuery:n.updateQuery.bind(n),startPolling:n.startPolling.bind(n),stopPolling:n.stopPolling.bind(n),subscribeToMore:n.subscribeToMore.bind(n)}}var a0=["refetch","reobserve","fetchMore","updateQuery","startPolling","stopPolling","subscribeToMore"];function Qu(n,e){var t,r=ge.useRef(void 0),i=ge.useRef(void 0),s=ge.useRef(void 0),l=cl(e,r.current||{}),c=(t=l==null?void 0:l.query)!==null&&t!==void 0?t:n;i.current=e,s.current=c;var u=xe(xe({},l),{skip:!r.current}),d=ju(c,u),h=d.obsQueryFields,p=d.result,y=d.client,g=d.resultData,_=d.observable,S=d.onQueryExecuted,k=_.options.initialFetchPolicy||_l(u.defaultOptions,y.defaultOptions),A=ge.useReducer(function(j){return j+1},0)[1],P=ge.useMemo(function(){for(var j={},V=function(_t){var Ke=h[_t];j[_t]=function(){return r.current||(r.current=Object.create(null),A()),Ke.apply(this,arguments)}},ne=0,ve=a0;ne<ve.length;ne++){var Le=ve[ne];V(Le)}return j},[A,h]),L=!!r.current,B=ge.useMemo(function(){return xe(xe(xe({},p),P),{called:L})},[p,P,L]),W=ge.useCallback(function(j){r.current=j?xe(xe({},j),{fetchPolicy:j.fetchPolicy||k}):{fetchPolicy:k};var V=cl(i.current,xe({query:s.current},r.current)),ne=c0(g,_,y,c,xe(xe({},V),{skip:!1}),S).then(function(ve){return Object.assign(ve,P)});return ne.catch(function(){}),ne},[y,c,P,k,_,g,S]),z=ge.useRef(W);Gy(function(){z.current=W});var J=ge.useCallback(function(){for(var j=[],V=0;V<arguments.length;V++)j[V]=arguments[V];return z.current.apply(z,j)},[]);return[J,B]}function c0(n,e,t,r,i,s){var l=i.query||r,c=qu(t,l,i,!1)(e),u=e.reobserveAsConcast(gl(e,t,i,c));return s(c),new Promise(function(d){var h;u.subscribe({next:function(p){h=p},error:function(){d(gs(e.getCurrentResult(),n.previousData,e,t))},complete:function(){d(gs(e.maskResult(h),n.previousData,e,t))}})})}const u0=(n,e)=>{const{data:t,loading:r,refetch:i,fetchMore:s}=ml(n,{...e,notifyOnNetworkStatusChange:!0,variables:{...e==null?void 0:e.variables,page:{first:(e==null?void 0:e.pageSize)??100}}}),l=n.definitions[0].selectionSet.selections[0].name.value;return{data:t,loading:r,loadNextPage:c=>{const u=t==null?void 0:t[l];if(u!=null&&u.pageInfo.hasNextPage)return i({...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u.pageInfo.endCursor}})},loadNextPageWithoutAppendingOldData:c=>{const u=t==null?void 0:t[l];return s({variables:{...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u==null?void 0:u.pageInfo.endCursor}}})}}},bl=(n,e)=>{const[t,r]=K.useState(!(e!=null&&e.skip)),[i,s]=K.useState([]),[l]=Qu(n,e),c=async u=>{var g;const d=n.definitions[0].selectionSet.selections[0].name.value;r(!0);let h=!0,p=null;const y=[];for(;h;){const{data:_,error:S}=await l({variables:{...e==null?void 0:e.variables,...u,page:{first:100,after:p}}});if(S)throw S;const k=_==null?void 0:_[d];k&&(y.push(...k.nodes??[]),h=k.pageInfo.hasNextPage,p=k.pageInfo.endCursor)}return s(y),(g=e==null?void 0:e.onResults)==null||g.call(e,y),r(!1),y};return K.useEffect(()=>{e!=null&&e.skip||c()},[e==null?void 0:e.skip]),{loading:t,results:i,refetch:c}};var vl={exports:{}},yi={};/**
1
+ (function(Je,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("react"),require("@well-played.gg/typescript-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@well-played.gg/typescript-sdk","react-dom"],K):(Je=typeof globalThis<"u"?globalThis:Je||self,K(Je.WellPlayedReactSDK={},Je.React,Je.typescriptSdk,Je.ReactDOM))})(this,function(Je,K,sr,gy){"use strict";function yy(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in n)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var nl=function(n,e){return nl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},nl(n,e)};function bu(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");nl(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var xe=function(){return xe=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},xe.apply(this,arguments)};function vu(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function Rr(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var rl="Invariant Violation",wu=Object.setPrototypeOf,_y=wu===void 0?function(n,e){return n.__proto__=e,n}:wu,by=function(n){bu(e,n);function e(t){t===void 0&&(t=rl);var r=n.call(this,typeof t=="number"?rl+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return r.framesToPop=1,r.name=rl,_y(r,e.prototype),r}return e}(Error);function or(n,e){if(!n)throw new by(e)}var Su=["debug","log","warn","error","silent"],vy=Su.indexOf("log");function hs(n){return function(){if(Su.indexOf(n)>=vy){var e=console[n]||console.log;return e.apply(console,arguments)}}}(function(n){n.debug=hs("debug"),n.log=hs("log"),n.warn=hs("warn"),n.error=hs("error")})(or||(or={}));var ku="3.13.5";function hn(n){try{return n()}catch{}}const il=hn(function(){return globalThis})||hn(function(){return window})||hn(function(){return self})||hn(function(){return global})||hn(function(){return hn.constructor("return this")()});var xu=new Map;function wy(n){var e=xu.get(n)||1;return xu.set(n,e+1),"".concat(n,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function Sy(n,e){var t=wy("stringifyForDisplay");return JSON.stringify(n,function(r,i){return i===void 0?t:i},e).split(JSON.stringify(t)).join("<undefined>")}function ps(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(typeof e=="number"){var i=e;e=Ou(i),e||(e=Au(i,t),t=[])}n.apply(void 0,[e].concat(t))}}var nn=Object.assign(function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];e||or(e,Ou(t,r)||Au(t,r))},{debug:ps(or.debug),log:ps(or.log),warn:ps(or.warn),error:ps(or.error)}),Eu=Symbol.for("ApolloErrorMessageHandler_"+ku);function Tu(n){if(typeof n=="string")return n;try{return Sy(n,2).slice(0,1e3)}catch{return"<non-serializable>"}}function Ou(n,e){if(e===void 0&&(e=[]),!!n)return il[Eu]&&il[Eu](n,e.map(Tu))}function Au(n,e){if(e===void 0&&(e=[]),!!n)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:ku,message:n,args:e.map(Tu)})))}var ky=hn(function(){return navigator.product})=="ReactNative",xy=typeof Symbol=="function"&&typeof Symbol.for=="function",Cu=typeof hn(function(){return window.document.createElement})=="function",Ey=hn(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1,Ty=(Cu||ky)&&!Ey;function sl(n){return n!==null&&typeof n=="object"}function ol(){}const Oy=ol,Ay=typeof WeakRef<"u"?WeakRef:function(n){return{deref:()=>n}},Cy=typeof WeakMap<"u"?WeakMap:Map,My=typeof FinalizationRegistry<"u"?FinalizationRegistry:function(){return{register:ol,unregister:ol}},Ny=10024;class Mu{constructor(e=1/0,t=Oy){this.max=e,this.dispose=t,this.map=new Cy,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const r=this.unfinalizedNodes.values();for(let i=0;i<Ny;i++){const s=r.next().value;if(!s)break;this.unfinalizedNodes.delete(s);const l=s.key;delete s.key,s.keyRef=new Ay(l),this.registry.register(l,s,s)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new My(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.scheduleFinalization(r),this.map.set(e,r),this.size++,r.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return t?(this.deleteNode(t),!0):!1}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}var ll=new WeakSet;function Iy(n){n.size<=(n.max||-1)||ll.has(n)||(ll.add(n),setTimeout(function(){n.clean(),ll.delete(n)},100))}var Py=function(n,e){var t=new Mu(n,e);return t.set=function(r,i){var s=Mu.prototype.set.call(this,r,i);return Iy(this),s},t},Ry=Symbol.for("apollo.cacheSize"),Dy=xe({},il[Ry]);function Nu(n){return Array.isArray(n)&&n.length>0}function Ly(n){var e=new Set([n]);return e.forEach(function(t){sl(t)&&By(t)===t&&Object.getOwnPropertyNames(t).forEach(function(r){sl(t[r])&&e.add(t[r])})}),n}function By(n){if(globalThis.__DEV__!==!1&&!Object.isFrozen(n))try{Object.freeze(n)}catch(e){if(e instanceof TypeError)return null;throw e}return n}function Iu(n){return globalThis.__DEV__!==!1&&Ly(n),n}function al(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Object.create(null);return n.forEach(function(r){r&&Object.keys(r).forEach(function(i){var s=r[i];s!==void 0&&(t[i]=s)})}),t}function cl(n,e){return al(n,e,e.variables&&{variables:al(xe(xe({},n&&n.variables),e.variables))})}var Fy=function(n){var e=Rr(Rr(Rr([],n.graphQLErrors,!0),n.clientErrors,!0),n.protocolErrors,!0);return n.networkError&&e.push(n.networkError),e.map(function(t){return sl(t)&&t.message||"Error message not found."}).join(`
2
+ `)},Pu=function(n){bu(e,n);function e(t){var r=t.graphQLErrors,i=t.protocolErrors,s=t.clientErrors,l=t.networkError,c=t.errorMessage,u=t.extraInfo,d=n.call(this,c)||this;return d.name="ApolloError",d.graphQLErrors=r||[],d.protocolErrors=i||[],d.clientErrors=s||[],d.networkError=l||null,d.message=c||Fy(d),d.extraInfo=u,d.cause=Rr(Rr(Rr([l],r||[],!0),i||[],!0),s||[],!0).find(function(h){return!!h})||null,d.__proto__=e.prototype,d}return e}(Error);const{toString:Ru,hasOwnProperty:zy}=Object.prototype,Du=Function.prototype.toString,ul=new Map;function fl(n,e){try{return dl(n,e)}finally{ul.clear()}}function dl(n,e){if(n===e)return!0;const t=Ru.call(n),r=Ru.call(e);if(t!==r)return!1;switch(t){case"[object Array]":if(n.length!==e.length)return!1;case"[object Object]":{if(Bu(n,e))return!0;const i=Lu(n),s=Lu(e),l=i.length;if(l!==s.length)return!1;for(let c=0;c<l;++c)if(!zy.call(e,i[c]))return!1;for(let c=0;c<l;++c){const u=i[c];if(!dl(n[u],e[u]))return!1}return!0}case"[object Error]":return n.name===e.name&&n.message===e.message;case"[object Number]":if(n!==n)return e!==e;case"[object Boolean]":case"[object Date]":return+n==+e;case"[object RegExp]":case"[object String]":return n==`${e}`;case"[object Map]":case"[object Set]":{if(n.size!==e.size)return!1;if(Bu(n,e))return!0;const i=n.entries(),s=t==="[object Map]";for(;;){const l=i.next();if(l.done)break;const[c,u]=l.value;if(!e.has(c)||s&&!dl(u,e.get(c)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":n=new Uint8Array(n),e=new Uint8Array(e);case"[object DataView]":{let i=n.byteLength;if(i===e.byteLength)for(;i--&&n[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const i=Du.call(n);return i!==Du.call(e)?!1:!Vy(i,$y)}}return!1}function Lu(n){return Object.keys(n).filter(Wy,n)}function Wy(n){return this[n]!==void 0}const $y="{ [native code] }";function Vy(n,e){const t=n.length-e.length;return t>=0&&n.indexOf(e,t)===t}function Bu(n,e){let t=ul.get(n);if(t){if(t.has(e))return!0}else ul.set(n,t=new Set);return t.add(e),!1}var lr;(function(n){n[n.loading=1]="loading",n[n.setVariables=2]="setVariables",n[n.fetchMore=3]="fetchMore",n[n.refetch=4]="refetch",n[n.poll=6]="poll",n[n.ready=7]="ready",n[n.error=8]="error"})(lr||(lr={}));var mi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fu={exports:{}};(function(n){n.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=void 0,n.exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,n.exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,Object.assign(n.exports,K)})(Fu);var ge=Fu.exports;const zu=yy({__proto__:null,default:Hy(ge)},[ge]);var Wu=xy?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function hl(){nn("createContext"in zu,54);var n=ge.createContext[Wu];return n||(Object.defineProperty(ge.createContext,Wu,{value:n=ge.createContext({}),enumerable:!1,writable:!1,configurable:!0}),n.displayName="ApolloContext"),n}var Uy=function(n){var e=n.client,t=n.children,r=hl(),i=ge.useContext(r),s=ge.useMemo(function(){return xe(xe({},i),{client:e||i.client})},[i,e]);return nn(s.client,55),ge.createElement(r.Provider,{value:s},t)};function $u(n){var e=ge.useContext(hl()),t=n||e.client;return nn(!!t,58),t}var Vu=!1,Ky="useSyncExternalStore",jy=zu[Ky],qy=jy||function(n,e,t){var r=e();globalThis.__DEV__!==!1&&!Vu&&r!==e()&&(Vu=!0,globalThis.__DEV__!==!1&&nn.error(68));var i=ge.useState({inst:{value:r,getSnapshot:e}}),s=i[0].inst,l=i[1];return Ty?ge.useLayoutEffect(function(){Object.assign(s,{value:r,getSnapshot:e}),pl(s)&&l({inst:s})},[n,r,e]):Object.assign(s,{value:r,getSnapshot:e}),ge.useEffect(function(){return pl(s)&&l({inst:s}),n(function(){pl(s)&&l({inst:s})})},[n]),r};function pl(n){var e=n.value,t=n.getSnapshot;try{return e!==t()}catch{return!0}}var pn;(function(n){n[n.Query=0]="Query",n[n.Mutation=1]="Mutation",n[n.Subscription=2]="Subscription"})(pn||(pn={}));var gi;function Hu(n){var e;switch(n){case pn.Query:e="Query";break;case pn.Mutation:e="Mutation";break;case pn.Subscription:e="Subscription";break}return e}function Uu(n){gi||(gi=new Py(Dy.parser||1e3));var e=gi.get(n);if(e)return e;var t,r,i;nn(!!n&&!!n.kind,70,n);for(var s=[],l=[],c=[],u=[],d=0,h=n.definitions;d<h.length;d++){var p=h[d];if(p.kind==="FragmentDefinition"){s.push(p);continue}if(p.kind==="OperationDefinition")switch(p.operation){case"query":l.push(p);break;case"mutation":c.push(p);break;case"subscription":u.push(p);break}}nn(!s.length||l.length||c.length||u.length,71),nn(l.length+c.length+u.length<=1,72,n,l.length,u.length,c.length),r=l.length?pn.Query:pn.Mutation,!l.length&&!c.length&&(r=pn.Subscription);var y=l.length?l:c.length?c:u;nn(y.length===1,73,n,y.length);var g=y[0];t=g.variableDefinitions||[],g.name&&g.name.kind==="Name"?i=g.name.value:i="data";var _={name:i,type:r,variables:t};return gi.set(n,_),_}Uu.resetCache=function(){gi=void 0};function Jy(n,e){var t=Uu(n),r=Hu(e),i=Hu(t.type);nn(t.type===e,74,r,r,i)}var Gy=Cu?ge.useLayoutEffect:ge.useEffect,Yy=Symbol.for("apollo.hook.wrappers");function Qy(n,e,t){var r=t.queryManager,i=r&&r[Yy],s=i&&i[n];return s?s(e):e}var Xy=Object.prototype.hasOwnProperty;function Ku(){}var ms=Symbol();function ml(n,e){return e===void 0&&(e=Object.create(null)),Qy("useQuery",Zy,$u(e&&e.client))(n,e)}function Zy(n,e){var t=ju(n,e),r=t.result,i=t.obsQueryFields;return ge.useMemo(function(){return xe(xe({},r),i)},[r,i])}function e0(n,e,t,r,i){function s(p){var y;Jy(e,pn.Query);var g={client:n,query:e,observable:r&&r.getSSRObservable(i())||n.watchQuery(gl(void 0,n,t,i())),resultData:{previousData:(y=p==null?void 0:p.resultData.current)===null||y===void 0?void 0:y.data}};return g}var l=ge.useState(s),c=l[0],u=l[1];function d(p){var y,g;Object.assign(c.observable,(y={},y[ms]=p,y));var _=c.resultData;u(xe(xe({},c),{query:p.query,resultData:Object.assign(_,{previousData:((g=_.current)===null||g===void 0?void 0:g.data)||_.previousData,current:void 0})}))}if(n!==c.client||e!==c.query){var h=s(c);return u(h),[h,d]}return[c,d]}function ju(n,e){var t=$u(e.client),r=ge.useContext(hl()).renderPromises,i=!!r,s=t.disableNetworkFetches,l=e.ssr!==!1&&!e.skip,c=e.partialRefetch,u=qu(t,n,e,i),d=e0(t,n,e,r,u),h=d[0],p=h.observable,y=h.resultData,g=d[1],_=u(p);r0(y,p,t,e,_);var S=ge.useMemo(function(){return l0(p)},[p]);n0(p,r,l);var k=t0(y,p,t,e,_,s,c,i,{onCompleted:e.onCompleted||Ku,onError:e.onError||Ku});return{result:k,obsQueryFields:S,observable:p,resultData:y,client:t,onQueryExecuted:g}}function t0(n,e,t,r,i,s,l,c,u){var d=ge.useRef(u);ge.useEffect(function(){d.current=u});var h=(c||s)&&r.ssr===!1&&!r.skip?Gu:r.skip||i.fetchPolicy==="standby"?Yu:void 0,p=n.previousData,y=ge.useMemo(function(){return h&&gs(h,p,e,t)},[t,e,h,p]);return qy(ge.useCallback(function(g){if(c)return function(){};var _=function(){var A=n.current,P=e.getCurrentResult();A&&A.loading===P.loading&&A.networkStatus===P.networkStatus&&fl(A.data,P.data)||yl(P,n,e,t,l,g,d.current)},S=function(A){if(k.current.unsubscribe(),k.current=e.resubscribeAfterError(_,S),!Xy.call(A,"graphQLErrors"))throw A;var P=n.current;(!P||P&&P.loading||!fl(A,P.error))&&yl({data:P&&P.data,error:A,loading:!1,networkStatus:lr.error},n,e,t,l,g,d.current)},k={current:e.subscribe(_,S)};return function(){setTimeout(function(){return k.current.unsubscribe()})}},[s,c,e,n,l,t]),function(){return y||Ju(n,e,d.current,l,t)},function(){return y||Ju(n,e,d.current,l,t)})}function n0(n,e,t){e&&t&&(e.registerSSRObservable(n),n.getCurrentResult().loading&&e.addObservableQueryPromise(n))}function r0(n,e,t,r,i){var s;e[ms]&&!fl(e[ms],i)&&(e.reobserve(gl(e,t,r,i)),n.previousData=((s=n.current)===null||s===void 0?void 0:s.data)||n.previousData,n.current=void 0),e[ms]=i}function qu(n,e,t,r){t===void 0&&(t={});var i=t.skip;t.ssr,t.onCompleted,t.onError;var s=t.defaultOptions,l=vu(t,["skip","ssr","onCompleted","onError","defaultOptions"]);return function(c){var u=Object.assign(l,{query:e});return r&&(u.fetchPolicy==="network-only"||u.fetchPolicy==="cache-and-network")&&(u.fetchPolicy="cache-first"),u.variables||(u.variables={}),i?(u.initialFetchPolicy=u.initialFetchPolicy||u.fetchPolicy||_l(s,n.defaultOptions),u.fetchPolicy="standby"):u.fetchPolicy||(u.fetchPolicy=(c==null?void 0:c.options.initialFetchPolicy)||_l(s,n.defaultOptions)),u}}function gl(n,e,t,r){var i=[],s=e.defaultOptions.watchQuery;return s&&i.push(s),t.defaultOptions&&i.push(t.defaultOptions),i.push(al(n&&n.options,r)),i.reduce(cl)}function yl(n,e,t,r,i,s,l){var c=e.current;c&&c.data&&(e.previousData=c.data),!n.error&&Nu(n.errors)&&(n.error=new Pu({graphQLErrors:n.errors})),e.current=gs(o0(n,t,i),e.previousData,t,r),s(),i0(n,c==null?void 0:c.networkStatus,l)}function i0(n,e,t){if(!n.loading){var r=s0(n);Promise.resolve().then(function(){r?t.onError(r):n.data&&e!==n.networkStatus&&n.networkStatus===lr.ready&&t.onCompleted(n.data)}).catch(function(i){globalThis.__DEV__!==!1&&nn.warn(i)})}}function Ju(n,e,t,r,i){return n.current||yl(e.getCurrentResult(),n,e,i,r,function(){},t),n.current}function _l(n,e){var t;return(n==null?void 0:n.fetchPolicy)||((t=e==null?void 0:e.watchQuery)===null||t===void 0?void 0:t.fetchPolicy)||"cache-first"}function s0(n){return Nu(n.errors)?new Pu({graphQLErrors:n.errors}):n.error}function gs(n,e,t,r){var i=n.data;n.partial;var s=vu(n,["data","partial"]),l=xe(xe({data:i},s),{client:r,observable:t,variables:t.variables,called:n!==Gu&&n!==Yu,previousData:e});return l}function o0(n,e,t){return n.partial&&t&&!n.loading&&(!n.data||Object.keys(n.data).length===0)&&e.options.fetchPolicy!=="cache-only"?(e.refetch(),xe(xe({},n),{loading:!0,networkStatus:lr.refetch})):n}var Gu=Iu({loading:!0,data:void 0,error:void 0,networkStatus:lr.loading}),Yu=Iu({loading:!1,data:void 0,error:void 0,networkStatus:lr.ready});function l0(n){return{refetch:n.refetch.bind(n),reobserve:n.reobserve.bind(n),fetchMore:n.fetchMore.bind(n),updateQuery:n.updateQuery.bind(n),startPolling:n.startPolling.bind(n),stopPolling:n.stopPolling.bind(n),subscribeToMore:n.subscribeToMore.bind(n)}}var a0=["refetch","reobserve","fetchMore","updateQuery","startPolling","stopPolling","subscribeToMore"];function Qu(n,e){var t,r=ge.useRef(void 0),i=ge.useRef(void 0),s=ge.useRef(void 0),l=cl(e,r.current||{}),c=(t=l==null?void 0:l.query)!==null&&t!==void 0?t:n;i.current=e,s.current=c;var u=xe(xe({},l),{skip:!r.current}),d=ju(c,u),h=d.obsQueryFields,p=d.result,y=d.client,g=d.resultData,_=d.observable,S=d.onQueryExecuted,k=_.options.initialFetchPolicy||_l(u.defaultOptions,y.defaultOptions),A=ge.useReducer(function(j){return j+1},0)[1],P=ge.useMemo(function(){for(var j={},V=function(_t){var Ke=h[_t];j[_t]=function(){return r.current||(r.current=Object.create(null),A()),Ke.apply(this,arguments)}},ne=0,ve=a0;ne<ve.length;ne++){var Le=ve[ne];V(Le)}return j},[A,h]),L=!!r.current,B=ge.useMemo(function(){return xe(xe(xe({},p),P),{called:L})},[p,P,L]),W=ge.useCallback(function(j){r.current=j?xe(xe({},j),{fetchPolicy:j.fetchPolicy||k}):{fetchPolicy:k};var V=cl(i.current,xe({query:s.current},r.current)),ne=c0(g,_,y,c,xe(xe({},V),{skip:!1}),S).then(function(ve){return Object.assign(ve,P)});return ne.catch(function(){}),ne},[y,c,P,k,_,g,S]),z=ge.useRef(W);Gy(function(){z.current=W});var J=ge.useCallback(function(){for(var j=[],V=0;V<arguments.length;V++)j[V]=arguments[V];return z.current.apply(z,j)},[]);return[J,B]}function c0(n,e,t,r,i,s){var l=i.query||r,c=qu(t,l,i,!1)(e),u=e.reobserveAsConcast(gl(e,t,i,c));return s(c),new Promise(function(d){var h;u.subscribe({next:function(p){h=p},error:function(){d(gs(e.getCurrentResult(),n.previousData,e,t))},complete:function(){d(gs(e.maskResult(h),n.previousData,e,t))}})})}const u0=(n,e)=>{const{data:t,loading:r,refetch:i,fetchMore:s}=ml(n,{...e,notifyOnNetworkStatusChange:!0,variables:{...e==null?void 0:e.variables,page:{first:(e==null?void 0:e.pageSize)??100}}}),l=n.definitions[0].selectionSet.selections[0].name.value;return{data:t,loading:r,loadNextPage:c=>{const u=t==null?void 0:t[l];if(u!=null&&u.pageInfo.hasNextPage)return i({...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u.pageInfo.endCursor}})},loadNextPageWithoutAppendingOldData:c=>{const u=t==null?void 0:t[l];return s({variables:{...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u==null?void 0:u.pageInfo.endCursor}}})}}},bl=(n,e)=>{const[t,r]=K.useState(!(e!=null&&e.skip)),[i,s]=K.useState([]),[l]=Qu(n,e),c=async u=>{var g;const d=n.definitions[0].selectionSet.selections[0].name.value;r(!0);let h=!0,p=null;const y=[];for(;h;){const{data:_,error:S}=await l({variables:{...e==null?void 0:e.variables,...u,page:{first:100,after:p}}});if(S)throw S;const k=_==null?void 0:_[d];k&&(y.push(...k.nodes??[]),h=k.pageInfo.hasNextPage,p=k.pageInfo.endCursor)}return s(y),(g=e==null?void 0:e.onResults)==null||g.call(e,y),r(!1),y};return K.useEffect(()=>{e!=null&&e.skip||c()},[e==null?void 0:e.skip]),{loading:t,results:i,refetch:c}};var vl={exports:{}},yi={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
5
5
  *
@@ -20,8 +20,8 @@
20
20
  <%s {...props} />
21
21
  React keys must be passed directly to JSX without using spread:
22
22
  let props = %s;
23
- <%s key={someKey} {...props} />`,je,Ne,Ft,Ne),uo[Ne+je]=!0)}if(Ne=null,Ee!==void 0&&(t(Ee),Ne=""+Ee),l(te)&&(t(te.key),Ne=""+te.key),"key"in te){Ee={};for(var Ki in te)Ki!=="key"&&(Ee[Ki]=te[Ki])}else Ee=te;return Ne&&c(Ee,typeof F=="function"?F.displayName||F.name||"Unknown":F),d(F,Ne,Xe,cn,i(),Ee,Gn,Ui)}function p(F){typeof F=="object"&&F!==null&&F.$$typeof===g&&F._store&&(F._store.validated=1)}var y=K,g=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ve=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Le=Object.prototype.hasOwnProperty,_t=Array.isArray,Ke=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(F){return F()}};var Me,ft={},Gt=y["react-stack-bottom-frame"].bind(y,s)(),wn=Ke(r(s)),uo={};_i.Fragment=S,_i.jsx=function(F,te,Ee,je,cn){var Xe=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,Ee,!1,je,cn,Xe?Error("react-stack-top-frame"):Gt,Xe?Ke(r(F)):wn)},_i.jsxs=function(F,te,Ee,je,cn){var Xe=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,Ee,!0,je,cn,Xe?Error("react-stack-top-frame"):Gt,Xe?Ke(r(F)):wn)}}()),_i}process.env.NODE_ENV==="production"?vl.exports=f0():vl.exports=d0();var Y=vl.exports;let Dr=class{open(e){window.location.href=e}reload(){window.location.reload()}getCurrentHref(){return window.location.href}getPath(){const e=window.location;return e.pathname+(e.search||"")+(e.hash||"")}getOrigin(){return window.origin}};const ef=2e3,Lr=console;let h0=class{constructor(e,t,r,i=ef,s=!0){this._callback=e,this._client_id=t,this._url=r,this._interval=i||ef,this._stopOnError=s;const l=r.indexOf("/",r.indexOf("//")+2);this._frame_origin=r.substring(0,l),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=r}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1)})}_message(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&(e.data==="error"?(Lr.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):e.data==="changed"?(Lr.debug(e),Lr.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):Lr.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))}start(e){Lr.debug("CheckSessionIFrame.start :"+e),this.stop();const t=()=>{this._frame.contentWindow.postMessage(this._client_id+" "+e,this._frame_origin)};t(),this._timer=window.setInterval(t,this._interval)}stop(){this._timer&&(Lr.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)}};const ae={service_worker_not_supported_by_browser:"service_worker_not_supported_by_browser",token_acquired:"token_acquired",logout_from_another_tab:"logout_from_another_tab",logout_from_same_tab:"logout_from_same_tab",token_renewed:"token_renewed",token_timer:"token_timer",loginAsync_begin:"loginAsync_begin",loginAsync_error:"loginAsync_error",loginCallbackAsync_begin:"loginCallbackAsync_begin",loginCallbackAsync_end:"loginCallbackAsync_end",loginCallbackAsync_error:"loginCallbackAsync_error",refreshTokensAsync_begin:"refreshTokensAsync_begin",refreshTokensAsync:"refreshTokensAsync",refreshTokensAsync_end:"refreshTokensAsync_end",refreshTokensAsync_error:"refreshTokensAsync_error",refreshTokensAsync_silent_error:"refreshTokensAsync_silent_error",tryKeepExistingSessionAsync_begin:"tryKeepExistingSessionAsync_begin",tryKeepExistingSessionAsync_end:"tryKeepExistingSessionAsync_end",tryKeepExistingSessionAsync_error:"tryKeepExistingSessionAsync_error",silentLoginAsync_begin:"silentLoginAsync_begin",silentLoginAsync:"silentLoginAsync",silentLoginAsync_end:"silentLoginAsync_end",silentLoginAsync_error:"silentLoginAsync_error",syncTokensAsync_begin:"syncTokensAsync_begin",syncTokensAsync_lock_not_available:"syncTokensAsync_lock_not_available",syncTokensAsync_end:"syncTokensAsync_end",syncTokensAsync_error:"syncTokensAsync_error",tokensInvalidAndWaitingActionsToRefresh:"tokensInvalidAndWaitingActionsToRefresh"},Nt=(n,e=sessionStorage)=>{const t=S=>(e[`oidc.${n}`]=JSON.stringify({tokens:null,status:S}),Promise.resolve()),r=async()=>{if(!e[`oidc.${n}`])return e[`oidc.${n}`]=JSON.stringify({tokens:null,status:null}),{tokens:null,status:null};const S=JSON.parse(e[`oidc.${n}`]);return Promise.resolve({tokens:S.tokens,status:S.status})},i=S=>{e[`oidc.${n}`]=JSON.stringify({tokens:S})},s=async S=>{e[`oidc.session_state.${n}`]=S},l=async()=>e[`oidc.session_state.${n}`],c=S=>{e[`oidc.nonce.${n}`]=S.nonce},u=S=>{e[`oidc.jwk.${n}`]=JSON.stringify(S)},d=()=>JSON.parse(e[`oidc.jwk.${n}`]),h=async()=>({nonce:e[`oidc.nonce.${n}`]}),p=async S=>{e[`oidc.dpop_nonce.${n}`]=S},y=()=>e[`oidc.dpop_nonce.${n}`],g=()=>e[`oidc.${n}`]?JSON.stringify({tokens:JSON.parse(e[`oidc.${n}`]).tokens}):null,_={};return{clearAsync:t,initAsync:r,setTokens:i,getTokens:g,setSessionStateAsync:s,getSessionStateAsync:l,setNonceAsync:c,getNonceAsync:h,setLoginParams:S=>{_[n]=S,e[`oidc.login.${n}`]=JSON.stringify(S)},getLoginParams:()=>{const S=e[`oidc.login.${n}`];return S?(_[n]||(_[n]=JSON.parse(S)),_[n]):(console.warn(`storage[oidc.login.${n}] is empty, you should have an bad OIDC or code configuration somewhere.`),null)},getStateAsync:async()=>e[`oidc.state.${n}`],setStateAsync:async S=>{e[`oidc.state.${n}`]=S},getCodeVerifierAsync:async()=>e[`oidc.code_verifier.${n}`],setCodeVerifierAsync:async S=>{e[`oidc.code_verifier.${n}`]=S},setDemonstratingProofOfPossessionNonce:p,getDemonstratingProofOfPossessionNonce:y,setDemonstratingProofOfPossessionJwkAsync:u,getDemonstratingProofOfPossessionJwkAsync:d}};var bi=(n=>(n.AutomaticBeforeTokenExpiration="AutomaticBeforeTokensExpiration",n.AutomaticOnlyWhenFetchExecuted="AutomaticOnlyWhenFetchExecuted",n))(bi||{});const p0=n=>decodeURIComponent(Array.prototype.map.call(atob(n),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),m0=n=>JSON.parse(p0(n.replaceAll(/-/g,"+").replaceAll(/_/g,"/"))),tf=n=>{try{return n&&g0(n,".")===2?m0(n.split(".")[1]):null}catch(e){console.warn(e)}return null},g0=(n,e)=>n.split(e).length-1,wl={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"};function y0(n,e,t){if(n.issuedAt){if(typeof n.issuedAt=="string")return parseInt(n.issuedAt,10)}else return e&&e.iat?e.iat:t&&t.iat?t.iat:new Date().getTime()/1e3;return n.issuedAt}const Sl=(n,e=null,t)=>{if(!n)return null;let r;const i=typeof n.expiresIn=="string"?parseInt(n.expiresIn,10):n.expiresIn;n.accessTokenPayload!==void 0?r=n.accessTokenPayload:r=tf(n.accessToken);let s;e!=null&&"idToken"in e&&!("idToken"in n)?s=e.idToken:s=n.idToken;const l=n.idTokenPayload?n.idTokenPayload:tf(s),c=l&&l.exp?l.exp:Number.MAX_VALUE,u=r&&r.exp?r.exp:n.issuedAt+i;n.issuedAt=y0(n,r,l);let d;n.expiresAt?d=n.expiresAt:t===wl.access_token_invalid?d=u:t===wl.id_token_invalid?d=c:d=c<u?c:u;const h={...n,idTokenPayload:l,accessTokenPayload:r,expiresAt:d,idToken:s};if(e!=null&&"refreshToken"in e&&!("refreshToken"in n)){const p=e.refreshToken;return{...h,refreshToken:p}}return h},kl=(n,e,t)=>{if(!n)return null;if(!n.issued_at){const i=new Date().getTime()/1e3;n.issued_at=i}const r={accessToken:n.access_token,expiresIn:n.expires_in,idToken:n.id_token,scope:n.scope,tokenType:n.token_type,issuedAt:n.issued_at};return"refresh_token"in n&&(r.refreshToken=n.refresh_token),n.accessTokenPayload!==void 0&&(r.accessTokenPayload=n.accessTokenPayload),n.idTokenPayload!==void 0&&(r.idTokenPayload=n.idTokenPayload),Sl(r,e,t)},vi=(n,e)=>{const t=new Date().getTime()/1e3,r=e-t;return Math.round(r-n)},nf=(n,e=0)=>n?vi(e,n.expiresAt)>0:!1,rf=async(n,e=200,t=50)=>{let r=t;if(!n.getTokens())return null;for(;!nf(n.getTokens(),n.configuration.refresh_time_before_tokens_expiration_in_second)&&r>0;){if(n.configuration.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted){await n.renewTokensAsync({});break}else await _s({milliseconds:e});r=r-1}return{isTokensValid:nf(n.getTokens()),tokens:n.getTokens(),numberWaited:r-t}},sf=(n,e,t)=>{if(n.idTokenPayload){const r=n.idTokenPayload;if(t.issuer!==r.iss)return{isValid:!1,reason:`Issuer does not match (oidcServerConfiguration issuer) ${t.issuer} !== (idTokenPayload issuer) ${r.iss}`};const i=new Date().getTime()/1e3;if(r.exp&&r.exp<i)return{isValid:!1,reason:`Token expired (idTokenPayload exp) ${r.exp} < (currentTimeUnixSecond) ${i}`};const s=60*60*24*7;if(r.iat&&r.iat+s<i)return{isValid:!1,reason:`Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${r.iat+s} < (currentTimeUnixSecond) ${i}`};if(r.nonce&&r.nonce!==e)return{isValid:!1,reason:`Nonce does not match (idTokenPayload nonce) ${r.nonce} !== (nonce) ${e}`}}return{isValid:!0,reason:""}},Br=function(){const n=typeof window>"u"?global:window;return{setTimeout:setTimeout.bind(n),clearTimeout:clearTimeout.bind(n),setInterval:setInterval.bind(n),clearInterval:clearInterval.bind(n)}}(),of="7.25.7";let lf=null,ys;const _s=({milliseconds:n})=>new Promise(e=>Br.setTimeout(e,n)),af=(n="/")=>{try{ys=new AbortController,fetch(`${n}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,{signal:ys.signal}).catch(e=>{console.log(e)}),_s({milliseconds:150*1e3}).then(af)}catch(e){console.log(e)}},cf=()=>{ys&&ys.abort()},_0=(n="/")=>fetch(`${n}OidcKeepAliveServiceWorker.json`,{headers:{"oidc-vanilla":"true"}}).then(e=>e.statusText==="oidc-service-worker").catch(e=>{console.log(e)}),b0=n=>async(e,t)=>{t(),await e.update();const r=await e.unregister();console.log(`Service worker unregistration ${r?"successful":"failed"}`),await _s({milliseconds:2e3}),n.reload()},uf=n=>{const e=sessionStorage.getItem(`oidc.tabId.${n}`);if(e)return e;const t=globalThis.crypto.randomUUID();return sessionStorage.setItem(`oidc.tabId.${n}`,t),t},lt=n=>e=>new Promise(function(t,r){const i=new MessageChannel;i.port1.onmessage=function(s){s!=null&&s.data.error?r(s.data.error):t(s.data),i.port1.close(),i.port2.close()},n.active.postMessage({...e,tabId:uf(e.configurationName)},[i.port2])}),It=async(n,e)=>{var t;const r=n.service_worker_relative_url;if(typeof window>"u"||typeof navigator>"u"||!navigator.serviceWorker||!r||n.service_worker_activate()===!1)return null;let i=null;n.service_worker_register?i=await n.service_worker_register(r):(i=await navigator.serviceWorker.register(r),i.active&&i.waiting&&(console.log("Detected new service worker waiting, unregistering and reloading"),await((t=n.service_worker_update_require_callback)==null?void 0:t.call(n,i,cf))));try{await navigator.serviceWorker.ready,navigator.serviceWorker.controller||await lt(i)({type:"claim"})}catch(g){return console.warn(`Failed init ServiceWorker ${g.toString()}`),null}const s=async g=>lt(i)({type:"clear",data:{status:g},configurationName:e}),l=async(g,_,S)=>{var k;const A=await lt(i)({type:"init",data:{oidcServerConfiguration:g,where:_,oidcConfiguration:{token_renew_mode:S.token_renew_mode,service_worker_convert_all_requests_to_cors:S.service_worker_convert_all_requests_to_cors}},configurationName:e}),P=A.version;return P!==of&&(console.warn(`Service worker ${P} version mismatch with js client version ${of}, unregistering and reloading`),await((k=S.service_worker_update_require_callback)==null?void 0:k.call(S,i,cf))),{tokens:kl(A.tokens,null,S.token_renew_mode),status:A.status}},c=(g="/")=>{lf==null&&(lf="not_null",af(g))},u=g=>lt(i)({type:"setSessionState",data:{sessionState:g},configurationName:e}),d=async()=>(await lt(i)({type:"getSessionState",data:null,configurationName:e})).sessionState,h=g=>(sessionStorage[`oidc.nonce.${e}`]=g.nonce,lt(i)({type:"setNonce",data:{nonce:g},configurationName:e})),p=async()=>{let g=(await lt(i)({type:"getNonce",data:null,configurationName:e})).nonce;return g||(g=sessionStorage[`oidc.nonce.${e}`],console.warn("nonce not found in service worker, using sessionStorage")),{nonce:g}},y={};return{clearAsync:s,initAsync:l,startKeepAliveServiceWorker:()=>c(n.service_worker_keep_alive_path),isServiceWorkerProxyActiveAsync:()=>_0(n.service_worker_keep_alive_path),setSessionStateAsync:u,getSessionStateAsync:d,setNonceAsync:h,getNonceAsync:p,setLoginParams:g=>{y[e]=g,localStorage[`oidc.login.${e}`]=JSON.stringify(g)},getLoginParams:()=>{const g=localStorage[`oidc.login.${e}`];return y[e]||(y[e]=JSON.parse(g)),y[e]},getStateAsync:async()=>{let g=(await lt(i)({type:"getState",data:null,configurationName:e})).state;return g||(g=sessionStorage[`oidc.state.${e}`],console.warn("state not found in service worker, using sessionStorage")),g},setStateAsync:async g=>(sessionStorage[`oidc.state.${e}`]=g,lt(i)({type:"setState",data:{state:g},configurationName:e})),getCodeVerifierAsync:async()=>{let g=(await lt(i)({type:"getCodeVerifier",data:null,configurationName:e})).codeVerifier;return g||(g=sessionStorage[`oidc.code_verifier.${e}`],console.warn("codeVerifier not found in service worker, using sessionStorage")),g},setCodeVerifierAsync:async g=>(sessionStorage[`oidc.code_verifier.${e}`]=g,lt(i)({type:"setCodeVerifier",data:{codeVerifier:g},configurationName:e})),setDemonstratingProofOfPossessionNonce:async g=>{await lt(i)({type:"setDemonstratingProofOfPossessionNonce",data:{demonstratingProofOfPossessionNonce:g},configurationName:e})},getDemonstratingProofOfPossessionNonce:async()=>(await lt(i)({type:"getDemonstratingProofOfPossessionNonce",data:null,configurationName:e})).demonstratingProofOfPossessionNonce,setDemonstratingProofOfPossessionJwkAsync:async g=>{const _=JSON.stringify(g);await lt(i)({type:"setDemonstratingProofOfPossessionJwk",data:{demonstratingProofOfPossessionJwkJson:_},configurationName:e})},getDemonstratingProofOfPossessionJwkAsync:async()=>{const g=await lt(i)({type:"getDemonstratingProofOfPossessionJwk",data:null,configurationName:e});return g.demonstratingProofOfPossessionJwkJson?JSON.parse(g.demonstratingProofOfPossessionJwkJson):null}}},Fr={},v0=(n,e=window.sessionStorage,t)=>{if(!Fr[n]&&e){const i=e.getItem(n);i&&(Fr[n]=JSON.parse(i))}const r=1e3*t;return Fr[n]&&Fr[n].timestamp+r>Date.now()?Fr[n].result:null},w0=(n,e,t=window.sessionStorage)=>{const r=Date.now();Fr[n]={result:e,timestamp:r},t&&t.setItem(n,JSON.stringify({result:e,timestamp:r}))};function ff(n){return new TextEncoder().encode(n)}function df(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function S0(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}const xl=n=>{let e="";return n.forEach(function(t){e+=String.fromCharCode(t)}),df(e)};function hf(n){return df(S0(n))}const k0={importKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256",hash:{name:"ES256"}},signAlgorithm:{name:"ECDSA",hash:{name:"SHA-256"}},generateKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256"},digestAlgorithm:{name:"SHA-256"},jwtHeaderAlgorithm:"ES256"},x0=n=>async(e,t,r,i,s="dpop+jwt")=>{switch(e=Object.assign({},e),t.typ=s,t.alg=i.jwtHeaderAlgorithm,t.alg){case"ES256":t.jwk={kty:e.kty,crv:e.crv,x:e.x,y:e.y};break;case"RS256":t.jwk={kty:e.kty,n:e.n,e:e.e,kid:t.kid};break;default:throw new Error("Unknown or not implemented JWS algorithm")}const l={protected:hf(JSON.stringify(t)),payload:hf(JSON.stringify(r))},c=i.importKeyAlgorithm,u=!0,d=["sign"],h=await n.crypto.subtle.importKey("jwk",e,c,u,d),p=ff(`${l.protected}.${l.payload}`),y=i.signAlgorithm,g=await n.crypto.subtle.sign(y,h,p);return l.signature=xl(new Uint8Array(g)),`${l.protected}.${l.payload}.${l.signature}`},E0={sign:x0},T0=n=>async e=>{const t=e,r=!0,i=["sign","verify"],s=await n.crypto.subtle.generateKey(t,r,i);return await n.crypto.subtle.exportKey("jwk",s.privateKey)},O0=n=>{const e=Object.assign({},n);return delete e.d,e.key_ops=["verify"],e},A0={generate:T0,neuter:O0},C0=n=>async(e,t)=>{let r;switch(e.kty){case"EC":r='{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",e.crv).replace("X",e.x).replace("Y",e.y);break;case"RSA":r='{"e":"E","kty":"RSA","n":"N"}'.replace("E",e.e).replace("N",e.n);break;default:throw new Error("Unknown or not implemented JWK type")}const i=await n.crypto.subtle.digest(t,ff(r));return xl(new Uint8Array(i))},M0={thumbprint:C0},N0=n=>async e=>await A0.generate(n)(e),pf=n=>e=>async(t,r="POST",i,s={})=>{const l={jti:btoa(I0()),htm:r,htu:i,iat:Math.round(Date.now()/1e3),...s},c=await M0.thumbprint(n)(t,e.digestAlgorithm);return await E0.sign(n)(t,{kid:c},l,e)},I0=()=>{const n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",e="0123456789abcdef";let t=0,r="";for(let i=0;i<36;i++)n[i]!=="-"&&n[i]!=="4"&&(t=Math.random()*16|0),n[i]==="x"?r+=e[t]:n[i]==="y"?(t&=3,t|=8,r+=e[t]):r+=n[i];return r},mf=()=>{const n=typeof window<"u"&&!!window.crypto,e=n&&!!window.crypto.subtle;return{hasCrypto:n,hasSubtleCrypto:e}},El="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",P0=n=>{const e=[];for(let t=0;t<n.byteLength;t+=1){const r=n[t]%El.length;e.push(El[r])}return e.join("")},Tl=n=>{const e=new Uint8Array(n),{hasCrypto:t}=mf();if(t)window.crypto.getRandomValues(e);else for(let r=0;r<n;r+=1)e[r]=Math.random()*El.length|0;return P0(e)};function R0(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return t}function gf(n){return new Promise((e,t)=>{crypto.subtle.digest("SHA-256",R0(n)).then(r=>e(xl(new Uint8Array(r))),r=>t(r))})}const D0=n=>{if(n.length<43||n.length>128)return Promise.reject(new Error("Invalid code length."));const{hasSubtleCrypto:e}=mf();return e?gf(n):Promise.reject(new Error("window.crypto.subtle is unavailable."))},L0=60*60,B0=n=>async(e,t=L0,r=window.sessionStorage,i=1e4)=>{const s=`${e}/.well-known/openid-configuration`,l=`oidc.server:${e}`,c=v0(l,r,t);if(c)return new Ml(c);const u=await wi(n)(s,{},i);if(u.status!==200)return null;const d=await u.json();return w0(l,d,r),new Ml(d)},wi=n=>async(e,t={},r=1e4,i=0)=>{let s;try{const l=new AbortController;setTimeout(()=>l.abort(),r),s=await n(e,{...t,signal:l.signal})}catch(l){if(l.name==="AbortError"||l.message==="Network request failed"){if(i<=1)return await wi(n)(e,t,r,i+1);throw l}else throw console.error(l.message),l}return s},Ol={refresh_token:"refresh_token",access_token:"access_token"},yf=n=>async(e,t,r=Ol.refresh_token,i,s={},l=1e4)=>{const c={token:t,token_type_hint:r,client_id:i};for(const[h,p]of Object.entries(s))c[h]===void 0&&(c[h]=p);const u=[];for(const h in c){const p=encodeURIComponent(h),y=encodeURIComponent(c[h]);u.push(`${p}=${y}`)}const d=u.join("&");return(await wi(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:d},l)).status!==200?{success:!1}:{success:!0}},F0=n=>async(e,t,r,i,s={},l,c=1e4)=>{for(const[g,_]of Object.entries(r))t[g]===void 0&&(t[g]=_);const u=[];for(const g in t){const _=encodeURIComponent(g),S=encodeURIComponent(t[g]);u.push(`${_}=${S}`)}const d=u.join("&"),h=await wi(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...s},body:d},c);if(h.status!==200)return{success:!1,status:h.status,demonstratingProofOfPossessionNonce:null};const p=await h.json();let y=null;return h.headers.has(bs)&&(y=h.headers.get(bs)),{success:!0,status:h.status,data:kl(p,i,l),demonstratingProofOfPossessionNonce:y}},z0=(n,e)=>async(t,r)=>{r=r?{...r}:{};const i=Tl(128),s=await D0(i);await n.setCodeVerifierAsync(i),await n.setStateAsync(r.state),r.code_challenge=s,r.code_challenge_method="S256";let l="";if(r)for(const[c,u]of Object.entries(r))l===""?l+="?":l+="&",l+=`${c}=${encodeURIComponent(u)}`;e.open(`${t}${l}`)},bs="DPoP-Nonce",W0=n=>async(e,t,r,i,s=1e4)=>{t=t?{...t}:{},t.code_verifier=await n.getCodeVerifierAsync();const l=[];for(const p in t){const y=encodeURIComponent(p),g=encodeURIComponent(t[p]);l.push(`${y}=${g}`)}const c=l.join("&"),u=await wi(fetch)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...r},body:c},s);if(await Promise.all([n.setCodeVerifierAsync(null),n.setStateAsync(null)]),u.status!==200)return{success:!1,status:u.status};let d=null;u.headers.has(bs)&&(d=u.headers.get(bs));const h=await u.json();return{success:!0,data:{state:t.state,tokens:kl(h,null,i),demonstratingProofOfPossessionNonce:d}}};async function _f(n,e,t,r=null){const i=c=>{n.tokens=c},{tokens:s,status:l}=await vs(n)(i,0,e,t,r);return await It(n.configuration,n.configurationName)||await Nt(n.configurationName,n.configuration.storage).setTokens(n.tokens),n.tokens?s:(await n.destroyAsync(l),null)}async function bf(n,e=!1,t=null,r=null){const i=n.configuration,s=`${i.client_id}_${n.configurationName}_${i.authority}`;let l;const c=await It(n.configuration,n.configurationName);if((i==null?void 0:i.storage)===(window==null?void 0:window.sessionStorage)&&!c||!navigator.locks)l=await _f(n,e,t,r);else{let u="retry";for(;u==="retry";)u=await navigator.locks.request(s,{ifAvailable:!0},async d=>d?await _f(n,e,t,r):(n.publishEvent(mn.eventNames.syncTokensAsync_lock_not_available,{lock:"lock not available"}),"retry"));l=u}return l?(n.timeoutId&&(n.timeoutId=Si(n,n.tokens.expiresAt,t,r)),n.tokens):null}const Si=(n,e,t=null,r=null)=>{const i=n.configuration.refresh_time_before_tokens_expiration_in_second;return n.timeoutId&&Br.clearTimeout(n.timeoutId),Br.setTimeout(async()=>{const s={timeLeft:vi(i,e)};n.publishEvent(mn.eventNames.token_timer,s),await bf(n,!1,t,r)},1e3)},In={FORCE_REFRESH:"FORCE_REFRESH",SESSION_LOST:"SESSION_LOST",NOT_CONNECTED:"NOT_CONNECTED",TOKENS_VALID:"TOKENS_VALID",TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",LOGOUT_FROM_ANOTHER_TAB:"LOGOUT_FROM_ANOTHER_TAB",REQUIRE_SYNC_TOKENS:"REQUIRE_SYNC_TOKENS"},$0=n=>async(e,t,r,i=!1)=>{const s={nonce:null};if(!r)return{tokens:null,status:"NOT_CONNECTED",nonce:s};let l=s;const c=await n.initAsync(e.authority,e.authority_configuration),u=await It(e,t);if(u){const{status:h,tokens:p}=await u.initAsync(c,"syncTokensAsync",e);if(h==="LOGGED_OUT")return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};if(h==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(!h||!p)return{tokens:null,status:"REQUIRE_SYNC_TOKENS",nonce:s};if(p.issuedAt!==r.issuedAt){const y=vi(e.refresh_time_before_tokens_expiration_in_second,p.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",g=await u.getNonceAsync();return{tokens:p,status:y,nonce:g}}l=await u.getNonceAsync()}else{const h=Nt(t,e.storage??sessionStorage),p=await h.initAsync();let{tokens:y}=p;const{status:g}=p;if(y&&(y=Sl(y,n.tokens,e.token_renew_mode)),y){if(g==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(y.issuedAt!==r.issuedAt){const _=vi(e.refresh_time_before_tokens_expiration_in_second,y.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",S=await h.getNonceAsync();return{tokens:y,status:_,nonce:S}}}else return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};l=await h.getNonceAsync()}const d=vi(e.refresh_time_before_tokens_expiration_in_second,r.expiresAt)>0?"TOKENS_VALID":"TOKENS_INVALID";return i?{tokens:r,status:"FORCE_REFRESH",nonce:l}:{tokens:r,status:d,nonce:l}},vs=n=>async(e,t=0,r=!1,i=null,s=null)=>{if(!navigator.onLine&&document.hidden)return{tokens:n.tokens,status:"GIVE_UP"};let l=6;for(;!navigator.onLine&&l>0;)await _s({milliseconds:1e3}),l--,n.publishEvent(ae.refreshTokensAsync,{message:`wait because navigator is offline try ${l}`});const c=document.hidden,u=c?t:t+1;if(t>4)return c?{tokens:n.tokens,status:"GIVE_UP"}:(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token"}),{tokens:null,status:"SESSION_LOST"});i||(i={});const d=n.configuration,h=(y,g=null,_=null)=>Al(n.configurationName,n.configuration,n.publishEvent.bind(n))(y,g,_),p=async()=>{try{let y;const g=await It(d,n.configurationName);g?y=g.getLoginParams():y=Nt(n.configurationName,d.storage).getLoginParams();const _=await h({...y.extras,...i,prompt:"none",scope:s});return _?_.error?(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token silent"}),{tokens:null,status:"SESSION_LOST"}):(e(_.tokens),n.publishEvent(mn.eventNames.token_renewed,{}),{tokens:_.tokens,status:"LOGGED"}):(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token silent not active"}),{tokens:null,status:"SESSION_LOST"})}catch(y){return console.error(y),n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"exceptionSilent",exception:y.message}),await vs(n)(e,u,r,i,s)}};try{const{status:y,tokens:g,nonce:_}=await $0(n)(d,n.configurationName,n.tokens,r);switch(y){case In.SESSION_LOST:return e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token session lost"}),{tokens:null,status:"SESSION_LOST"};case In.NOT_CONNECTED:return e(null),{tokens:null,status:null};case In.TOKENS_VALID:return e(g),{tokens:g,status:"LOGGED_IN"};case In.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:return e(g),n.publishEvent(mn.eventNames.token_renewed,{reason:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"}),{tokens:g,status:"LOGGED_IN"};case In.LOGOUT_FROM_ANOTHER_TAB:return e(null),n.publishEvent(ae.logout_from_another_tab,{status:"session syncTokensAsync"}),{tokens:null,status:"LOGGED_OUT"};case In.REQUIRE_SYNC_TOKENS:return d.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted&&In.FORCE_REFRESH!==y?(n.publishEvent(ae.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"}):(n.publishEvent(ae.refreshTokensAsync_begin,{tryNumber:t}),await p());default:{if(d.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted&&In.FORCE_REFRESH!==y)return n.publishEvent(ae.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"};if(n.publishEvent(ae.refreshTokensAsync_begin,{refreshToken:g.refreshToken,status:y,tryNumber:t}),!g.refreshToken)return await p();const S=d.client_id,k=d.redirect_uri,A=d.authority,P={...d.token_request_extras?d.token_request_extras:{}};for(const[L,B]of Object.entries(i))L.endsWith(":token_request")&&(P[L.replace(":token_request","")]=B);return await(async()=>{const L={client_id:S,redirect_uri:k,grant_type:"refresh_token",refresh_token:g.refreshToken},B=await n.initAsync(A,d.authority_configuration),W=document.hidden?1e4:3e4*10,z=B.tokenEndpoint,J={};d.demonstrating_proof_of_possession&&(J.DPoP=await n.generateDemonstrationOfProofOfPossessionAsync(g.accessToken,z,"POST"));const j=await F0(n.getFetch())(z,L,P,g,J,d.token_renew_mode,W);if(j.success){const{isValid:V,reason:ne}=sf(j.data,_.nonce,B);if(!V)return e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:`refresh token return not valid tokens, reason: ${ne}`}),{tokens:null,status:"SESSION_LOST"};if(e(j.data),j.demonstratingProofOfPossessionNonce){const ve=await It(d,n.configurationName);ve?await ve.setDemonstratingProofOfPossessionNonce(j.demonstratingProofOfPossessionNonce):await Nt(n.configurationName,d.storage).setDemonstratingProofOfPossessionNonce(j.demonstratingProofOfPossessionNonce)}return n.publishEvent(ae.refreshTokensAsync_end,{success:j.success}),n.publishEvent(mn.eventNames.token_renewed,{reason:"REFRESH_TOKEN"}),{tokens:j.data,status:"LOGGED_IN"}}else return n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"bad request",tokenResponse:j}),j.status>=400&&j.status<500?(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:`session lost: ${j.status}`}),{tokens:null,status:"SESSION_LOST"}):await vs(n)(e,u,r,i,s)})()}}}catch(y){return console.error(y),n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"exception",exception:y.message}),new Promise((g,_)=>{setTimeout(()=>{vs(n)(e,u,r,i,s).then(g).catch(_)},1e3)})}},Al=(n,e,t)=>(r=null,i=null,s=null)=>{if(!e.silent_redirect_uri||!e.silent_login_uri)return Promise.resolve(null);try{t(ae.silentLoginAsync_begin,{});let l="";if(i&&(r==null&&(r={}),r.state=i),s!=null&&(r==null&&(r={}),r.scope=s),r!=null)for(const[p,y]of Object.entries(r))l===""?l=`?${encodeURIComponent(p)}=${encodeURIComponent(y)}`:l+=`&${encodeURIComponent(p)}=${encodeURIComponent(y)}`;const c=e.silent_login_uri+l,u=c.indexOf("/",c.indexOf("//")+2),d=c.substring(0,u),h=document.createElement("iframe");return h.width="0px",h.height="0px",h.id=`${n}_oidc_iframe`,h.setAttribute("src",c),document.body.appendChild(h),new Promise((p,y)=>{let g=!1;const _=()=>{window.removeEventListener("message",S),h.remove(),g=!0},S=k=>{if(k.origin===d&&k.source===h.contentWindow){const A=`${n}_oidc_tokens:`,P=`${n}_oidc_error:`,L=`${n}_oidc_exception:`,B=k.data;if(B&&typeof B=="string"&&!g){if(B.startsWith(A)){const W=JSON.parse(k.data.replace(A,""));t(ae.silentLoginAsync_end,{}),p(W),_()}else if(B.startsWith(P)){const W=JSON.parse(k.data.replace(P,""));t(ae.silentLoginAsync_error,W),p({error:"oidc_"+W.error,tokens:null,sessionState:null}),_()}else if(B.startsWith(L)){const W=JSON.parse(k.data.replace(L,""));t(ae.silentLoginAsync_error,W),y(new Error(W.error)),_()}}}};try{window.addEventListener("message",S);const k=e.silent_login_timeout;setTimeout(()=>{g||(_(),t(ae.silentLoginAsync_error,{reason:"timeout"}),y(new Error("timeout")))},k)}catch(k){_(),t(ae.silentLoginAsync_error,k),y(k)}})}catch(l){throw t(ae.silentLoginAsync_error,l),l}},V0=(n,e,t,r,i)=>(s=null,l=void 0)=>{s={...s};const c=(u,d,h)=>Al(e,t,r.bind(i))(u,d,h);return(async()=>{i.timeoutId&&Br.clearTimeout(i.timeoutId);let u;s&&"state"in s&&(u=s.state,delete s.state);try{const d=t.extras?{...t.extras,...s}:s,h=await c({...d,prompt:"none"},u,l);if(h)return i.tokens=h.tokens,r(ae.token_acquired,{}),i.timeoutId=Si(i,i.tokens.expiresAt,s,l),{}}catch(d){return d}})()},H0=(n,e,t)=>(r,i,s,l=!1)=>{const c=(u,d=void 0,h=void 0)=>Al(n.configurationName,t,n.publishEvent.bind(n))(u,d,h);return new Promise((u,d)=>{if(t.silent_login_uri&&t.silent_redirect_uri&&t.monitor_session&&r&&s&&!l){const h=()=>{n.checkSessionIFrame.stop();const p=n.tokens;if(p===null)return;const y=p.idToken,g=p.idTokenPayload;return c({prompt:"none",id_token_hint:y,scope:t.scope||"openid"}).then(_=>{if(_.error)throw new Error(_.error);const S=_.tokens.idTokenPayload;if(g.sub===S.sub){const k=_.sessionState;n.checkSessionIFrame.start(_.sessionState),g.sid===S.sid?console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",k):console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",k)}else console.debug("SessionMonitor._callback: Different subject signed into OP:",S.sub)}).catch(async _=>{console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:",_);for(const[,S]of Object.entries(e))await S.logoutOtherTabAsync(t.client_id,g.sub)})};n.checkSessionIFrame=new h0(h,i,r),n.checkSessionIFrame.load().then(()=>{n.checkSessionIFrame.start(s),u(n.checkSessionIFrame)}).catch(p=>{d(p)})}else u(null)})},U0=n=>!!(n.os==="iOS"&&n.osVersion.startsWith("12")||n.os==="Mac OS X"&&n.osVersion.startsWith("10_15_6")),K0=n=>{const e=n.appVersion,t=n.userAgent,r="-";let i=r;const s=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(const c in s){const u=s[c];if(u.r.test(t)){i=u.s;break}}let l=r;switch(/Windows/.test(i)&&(l=/Windows (.*)/.exec(i)[1],i="Windows"),i){case"Mac OS":case"Mac OS X":case"Android":l=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t)[1];break;case"iOS":{const c=/OS (\d+)_(\d+)_?(\d+)?/.exec(e);c!=null&&c.length>2&&(l=c[1]+"."+c[2]+"."+(parseInt(c[3])|0));break}}return{os:i,osVersion:l}};function j0(){const n=navigator.userAgent;let e,t=n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(t[1]))return e=/\brv[ :]+(\d+)/g.exec(n)||[],{name:"ie",version:e[1]||""};if(t[1]==="Chrome"&&(e=n.match(/\bOPR|Edge\/(\d+)/),e!=null)){let r=e[1];if(!r){const i=n.split(e[0]+"/");i.length>1&&(r=i[1])}return{name:"opera",version:r}}return t=t[2]?[t[1],t[2]]:[navigator.appName,navigator.appVersion,"-?"],(e=n.match(/version\/(\d+)/i))!=null&&t.splice(1,1,e[1]),{name:t[0].toLowerCase(),version:t[1]}}const q0=()=>{const{name:n,version:e}=j0();if(n==="chrome"&&parseInt(e)<=70||n==="opera"&&(!e||parseInt(e.split(".")[0])<80)||n==="ie")return!1;const t=K0(navigator);return!U0(t)},J0=async n=>{let e;if(n.tokens!=null)return!1;n.publishEvent(ae.tryKeepExistingSessionAsync_begin,{});try{const t=n.configuration,r=await n.initAsync(t.authority,t.authority_configuration);if(e=await It(t,n.configurationName),e){const{tokens:i}=await e.initAsync(r,"tryKeepExistingSessionAsync",t);if(i){e.startKeepAliveServiceWorker(),n.tokens=i;const s=e.getLoginParams(n.configurationName);n.timeoutId=Si(n,n.tokens.expiresAt,s.extras,s.scope);const l=await e.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,l),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside ServiceWorker are valid"}),!0}n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!1,message:"no exiting session found"})}else{t.service_worker_relative_url&&n.publishEvent(ae.service_worker_not_supported_by_browser,{message:"service worker is not supported by this browser"});const i=Nt(n.configurationName,t.storage??sessionStorage),{tokens:s}=await i.initAsync();if(s){n.tokens=Sl(s,null,t.token_renew_mode);const l=i.getLoginParams();n.timeoutId=Si(n,n.tokens.expiresAt,l.extras,l.scope);const c=await i.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,c),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside storage are valid"}),!0}}return n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!1,message:e?"service worker sessions not retrieved":"session storage sessions not retrieved"}),!1}catch(t){return console.error(t),e&&await e.clearAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_error,"tokens inside ServiceWorker are invalid"),!1}},vf=n=>{const e=n.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);if(!e)throw new Error("Invalid URL");let t=e[6],r=e[7];if(r){const i=r.split("?");i.length===2&&(r=i[0],t=i[1])}return t.startsWith("?")&&(t=t.slice(1)),e&&{href:n,protocol:e[1],host:e[2],hostname:e[3],port:e[4],path:e[5],search:t,hash:r}},ki=n=>{const e=vf(n);let{path:t}=e;t.endsWith("/")&&(t=t.slice(0,-1));let{hash:r}=e;return r==="#_=_"&&(r=""),r&&(t+=r),t},ws=n=>{const e=vf(n),{search:t}=e;return G0(t)},G0=n=>{const e={};let t,r,i;const s=n.split("&");for(r=0,i=s.length;r<i;r++)t=s[r].split("="),e[decodeURIComponent(t[0])]=decodeURIComponent(t[1]);return e},Y0=(n,e,t,r,i)=>(s=void 0,l=null,c=!1,u=void 0)=>{const d=l;return l={...l},(async()=>{const h=s||i.getPath();if("state"in l||(l.state=Tl(16)),t(ae.loginAsync_begin,{}),l)for(const p of Object.keys(l))p.endsWith(":token_request")&&delete l[p];try{const p=c?e.silent_redirect_uri:e.redirect_uri;u||(u=e.scope);const y=e.extras?{...e.extras,...l}:l;y.nonce||(y.nonce=Tl(12));const g={nonce:y.nonce},_=await It(e,n),S=await r(e.authority,e.authority_configuration);let k;if(_)_.setLoginParams({callbackPath:h,extras:d,scope:u}),await _.initAsync(S,"loginAsync",e),await _.setNonceAsync(g),_.startKeepAliveServiceWorker(),k=_;else{const P=Nt(n,e.storage??sessionStorage);P.setLoginParams({callbackPath:h,extras:d,scope:u}),await P.setNonceAsync(g),k=P}const A={client_id:e.client_id,redirect_uri:p,scope:u,response_type:"code",...y};await z0(k,i)(S.authorizationEndpoint,A)}catch(p){throw t(ae.loginAsync_error,p),p}})()},Q0=n=>async(e=!1)=>{try{n.publishEvent(ae.loginCallbackAsync_begin,{});const t=n.configuration,r=t.client_id,i=e?t.silent_redirect_uri:t.redirect_uri,s=t.authority,l=t.token_request_timeout,c=await n.initAsync(s,t.authority_configuration),u=n.location.getCurrentHref(),d=ws(u),h=d.session_state,p=await It(t,n.configurationName);let y,g,_,S;if(p)await p.initAsync(c,"loginCallbackAsync",t),await p.setSessionStateAsync(h),g=await p.getNonceAsync(),_=p.getLoginParams(),S=await p.getStateAsync(),p.startKeepAliveServiceWorker(),y=p;else{const ne=Nt(n.configurationName,t.storage??sessionStorage);await ne.setSessionStateAsync(h),g=await ne.getNonceAsync(),_=ne.getLoginParams(),S=await ne.getStateAsync(),y=ne}if(d.error||d.error_description)throw new Error(`Error from OIDC server: ${d.error} - ${d.error_description}`);if(d.iss&&d.iss!==c.issuer)throw console.error(),new Error(`Issuer not valid (expected: ${c.issuer}, received: ${d.iss})`);if(d.state&&d.state!==S)throw new Error(`State not valid (expected: ${S}, received: ${d.state})`);const k={code:d.code,grant_type:"authorization_code",client_id:t.client_id,redirect_uri:i},A={};if(t.token_request_extras)for(const[ne,ve]of Object.entries(t.token_request_extras))A[ne]=ve;if(_!=null&&_.extras)for(const[ne,ve]of Object.entries(_.extras))ne.endsWith(":token_request")&&(A[ne.replace(":token_request","")]=ve);const P=c.tokenEndpoint,L={};if(t.demonstrating_proof_of_possession)if(p)L.DPoP=`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${n.configurationName}`;else{const ne=await N0(window)(t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);await Nt(n.configurationName,t.storage).setDemonstratingProofOfPossessionJwkAsync(ne),L.DPoP=await pf(window)(t.demonstrating_proof_of_possession_configuration)(ne,"POST",P)}const B=await W0(y)(P,{...k,...A},L,n.configuration.token_renew_mode,l);if(!B.success)throw new Error("Token request failed");let W;const z=B.data.tokens,J=B.data.demonstratingProofOfPossessionNonce;if(B.data.state!==A.state)throw new Error("state is not valid");const{isValid:j,reason:V}=sf(z,g.nonce,c);if(!j)throw new Error(`Tokens are not OpenID valid, reason: ${V}`);if(p){if(z.refreshToken&&!z.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Refresh token should be hidden by service worker");if(J&&z!=null&&z.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Demonstration of proof of possession require Access token not hidden by service worker")}if(p)await p.initAsync(c,"syncTokensAsync",t),W=p.getLoginParams(),J&&await p.setDemonstratingProofOfPossessionNonce(J);else{const ne=Nt(n.configurationName,t.storage);W=ne.getLoginParams(),J&&await ne.setDemonstratingProofOfPossessionNonce(J)}return await n.startCheckSessionAsync(c.checkSessionIframe,r,h,e),n.publishEvent(ae.loginCallbackAsync_end,{}),{tokens:z,state:"request.state",callbackPath:W.callbackPath,scope:d.scope,extras:W.extras}}catch(t){throw console.error(t),n.publishEvent(ae.loginCallbackAsync_error,t),t}},wf={access_token:"access_token",refresh_token:"refresh_token"},Cl=(n,e)=>{const t={};if(n){for(const[r,i]of Object.entries(n))if(r.endsWith(e)){const s=r.replace(e,"");t[s]=i}return t}return t},X0=n=>{const e={};if(n){for(const[t,r]of Object.entries(n))t.includes(":")||(e[t]=r);return e}return e},Z0=n=>async e=>{Br.clearTimeout(n.timeoutId),n.timeoutId=null,n.checkSessionIFrame&&n.checkSessionIFrame.stop();const t=await It(n.configuration,n.configurationName);t?await t.clearAsync(e):await Nt(n.configurationName,n.configuration.storage).clearAsync(e),n.tokens=null,n.userInfo=null},e_=(n,e,t,r,i)=>async(s=void 0,l=null)=>{var c,u;const d=n.configuration,h=await n.initAsync(d.authority,d.authority_configuration);s&&typeof s!="string"&&(s=void 0,r.warn("callbackPathOrUrl path is not a string"));const p=s??i.getPath();let y=!1;s&&(y=s.includes("https://")||s.includes("http://"));const g=y?s:i.getOrigin()+p,_=n.tokens?n.tokens.idToken:"";try{const P=h.revocationEndpoint;if(P){const L=[],B=n.tokens?n.tokens.accessToken:null;if(B&&d.logout_tokens_to_invalidate.includes(wf.access_token)){const z=Cl(l,":revoke_access_token"),J=yf(t)(P,B,Ol.access_token,d.client_id,z);L.push(J)}const W=n.tokens?n.tokens.refreshToken:null;if(W&&d.logout_tokens_to_invalidate.includes(wf.refresh_token)){const z=Cl(l,":revoke_refresh_token"),J=yf(t)(P,W,Ol.refresh_token,d.client_id,z);L.push(J)}L.length>0&&await Promise.all(L)}}catch(P){r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"),r.warn(P)}const S=((u=(c=n.tokens)==null?void 0:c.idTokenPayload)==null?void 0:u.sub)??null;await n.destroyAsync("LOGGED_OUT");for(const[,P]of Object.entries(e))P!==n?await n.logoutSameTabAsync(n.configuration.client_id,S):n.publishEvent(ae.logout_from_same_tab,{});const k=Cl(l,":oidc");if(k&&k.no_reload==="true")return;const A=X0(l);if(h.endSessionEndpoint){"id_token_hint"in A||(A.id_token_hint=_),!("post_logout_redirect_uri"in A)&&s!==null&&(A.post_logout_redirect_uri=g);let P="";for(const[L,B]of Object.entries(A))B!=null&&(P===""?P+="?":P+="&",P+=`${L}=${encodeURIComponent(B)}`);i.open(`${h.endSessionEndpoint}${P}`)}else i.reload()},Sf=(n,e,t=!1)=>async(...r)=>{var i;const[s,l,...c]=r,u=l?{...l}:{method:"GET"};let d=new Headers;u.headers&&(d=u.headers instanceof Headers?u.headers:new Headers(u.headers));const h={getTokens:()=>e.tokens,configuration:{token_automatic_renew_mode:e.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:e.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:e.renewTokensAsync.bind(e)},p=await rf(h),y=(i=p==null?void 0:p.tokens)==null?void 0:i.accessToken;if(d.has("Accept")||d.set("Accept","application/json"),y){if(e.configuration.demonstrating_proof_of_possession&&t){const _=await e.generateDemonstrationOfProofOfPossessionAsync(y,s.toString(),u.method);d.set("Authorization",`DPoP ${y}`),d.set("DPoP",_)}else d.set("Authorization",`Bearer ${y}`);u.credentials||(u.credentials="same-origin")}const g={...u,headers:d};return await n(s,g,...c)},t_=n=>async(e=!1,t=!1)=>{if(n.userInfo!=null&&!e)return n.userInfo;const r=n.configuration,i=(await n.initAsync(r.authority,r.authority_configuration)).userInfoEndpoint,s=await(async()=>{const l=await Sf(fetch,n,t)(i);return l.status!==200?null:l.json()})();return n.userInfo=s,s},kf=()=>fetch;let Ml=class{constructor(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.checkSessionIframe=e.check_session_iframe,this.issuer=e.issuer,this.endSessionEndpoint=e.end_session_endpoint}};const lr={},n_=(n,e=new Dr)=>(t,r="default")=>(lr[r]||(lr[r]=new mn(t,r,n,e)),lr[r]),r_=async n=>{const{parsedTokens:e,callbackPath:t,extras:r,scope:i}=await n.loginCallbackAsync();return n.timeoutId=Si(n,e.expiresAt,r,i),{callbackPath:t}},i_=n=>Math.floor(Math.random()*n),Nl=class hy{constructor(e,t="default",r,i=new Dr){this.initPromise=null,this.tryKeepExistingSessionPromise=null,this.loginPromise=null,this.loginCallbackPromise=null,this.loginCallbackWithAutoTokensRenewPromise=null,this.userInfoPromise=null,this.renewTokensPromise=null,this.logoutPromise=null;let s=e.silent_login_uri;e.silent_redirect_uri&&!e.silent_login_uri&&(s=`${e.silent_redirect_uri.replace("-callback","").replace("callback","")}-login`);let l=e.refresh_time_before_tokens_expiration_in_second??120;l>60&&(l=l-Math.floor(Math.random()*40)),this.location=i??new Dr;const c=e.service_worker_update_require_callback??b0(this.location);this.configuration={...e,silent_login_uri:s,token_automatic_renew_mode:e.token_automatic_renew_mode??bi.AutomaticBeforeTokenExpiration,monitor_session:e.monitor_session??!1,refresh_time_before_tokens_expiration_in_second:l,silent_login_timeout:e.silent_login_timeout??12e3,token_renew_mode:e.token_renew_mode??wl.access_token_or_id_token_invalid,demonstrating_proof_of_possession:e.demonstrating_proof_of_possession??!1,authority_timeout_wellknowurl_in_millisecond:e.authority_timeout_wellknowurl_in_millisecond??1e4,logout_tokens_to_invalidate:e.logout_tokens_to_invalidate??["access_token","refresh_token"],service_worker_update_require_callback:c,service_worker_activate:e.service_worker_activate??q0,demonstrating_proof_of_possession_configuration:e.demonstrating_proof_of_possession_configuration??k0,preload_user_info:e.preload_user_info??!1},this.getFetch=r??kf,this.configurationName=t,this.tokens=null,this.userInfo=null,this.events=[],this.timeoutId=null,this.loginCallbackWithAutoTokensRenewAsync.bind(this),this.initAsync.bind(this),this.loginCallbackAsync.bind(this),this.subscribeEvents.bind(this),this.removeEventSubscription.bind(this),this.publishEvent.bind(this),this.destroyAsync.bind(this),this.logoutAsync.bind(this),this.renewTokensAsync.bind(this),this.initAsync(this.configuration.authority,this.configuration.authority_configuration)}subscribeEvents(e){const t=i_(9999999999999).toString();return this.events.push({id:t,func:e}),t}removeEventSubscription(e){const t=this.events.filter(r=>r.id!==e);this.events=t}publishEvent(e,t){this.events.forEach(r=>{r.func(e,t)})}static get(e="default"){const t=typeof process>"u";if(!Object.prototype.hasOwnProperty.call(lr,e)&&t)throw Error(`OIDC library does seem initialized.
24
- Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> component.`);return lr[e]}_silentLoginCallbackFromIFrame(){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const e=this.location,t=ws(e.getCurrentHref());window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({tokens:this.tokens,sessionState:t.session_state})}`,e.getOrigin())}}_silentLoginErrorCallbackFromIFrame(e=null){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const t=this.location,r=ws(t.getCurrentHref());r.error?window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({error:r.error})}`,t.getOrigin()):window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({error:e==null?"":e.toString()})}`,t.getOrigin())}}async silentLoginCallbackAsync(){try{await this.loginCallbackAsync(!0),this._silentLoginCallbackFromIFrame()}catch(e){console.error(e),this._silentLoginErrorCallbackFromIFrame(e)}}async initAsync(e,t){if(this.initPromise!==null)return this.initPromise;const r=async()=>{if(t!=null)return new Ml({authorization_endpoint:t.authorization_endpoint,end_session_endpoint:t.end_session_endpoint,revocation_endpoint:t.revocation_endpoint,token_endpoint:t.token_endpoint,userinfo_endpoint:t.userinfo_endpoint,check_session_iframe:t.check_session_iframe,issuer:t.issuer});const i=await It(this.configuration,this.configurationName)?window.sessionStorage:null;return await B0(this.getFetch())(e,this.configuration.authority_time_cache_wellknowurl_in_second??60*60,i,this.configuration.authority_timeout_wellknowurl_in_millisecond)};return this.initPromise=r(),this.initPromise.finally(()=>{this.initPromise=null})}async tryKeepExistingSessionAsync(){return this.tryKeepExistingSessionPromise!==null?this.tryKeepExistingSessionPromise:(this.tryKeepExistingSessionPromise=J0(this),this.tryKeepExistingSessionPromise.finally(()=>{this.tryKeepExistingSessionPromise=null}))}async startCheckSessionAsync(e,t,r,i=!1){await H0(this,lr,this.configuration)(e,t,r,i)}async loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this.logoutPromise&&await this.logoutPromise,this.loginPromise!==null?this.loginPromise:(s?this.loginPromise=V0(window,this.configurationName,this.configuration,this.publishEvent.bind(this),this)(t,i):this.loginPromise=Y0(this.configurationName,this.configuration,this.publishEvent.bind(this),this.initAsync.bind(this),this.location)(e,t,r,i),this.loginPromise.finally(()=>{this.loginPromise=null}))}async loginCallbackAsync(e=!1){if(this.loginCallbackPromise!==null)return this.loginCallbackPromise;const t=async()=>{const r=await Q0(this)(e),i=r.tokens;return this.tokens=i,await It(this.configuration,this.configurationName)||Nt(this.configurationName,this.configuration.storage).setTokens(i),this.publishEvent(hy.eventNames.token_acquired,i),this.configuration.preload_user_info&&await this.userInfoAsync(),{parsedTokens:i,state:r.state,callbackPath:r.callbackPath,scope:r.scope,extras:r.extras}};return this.loginCallbackPromise=t(),this.loginCallbackPromise.finally(()=>{this.loginCallbackPromise=null})}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){const s=this.configuration,l={ath:await gf(e),...i};if(await It(s,this.configurationName))return`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${uf(this.configurationName)}`;const c=Nt(this.configurationName,s.storage),u=await c.getDemonstratingProofOfPossessionJwkAsync(),d=c.getDemonstratingProofOfPossessionNonce();return d&&(l.nonce=d),await pf(window)(s.demonstrating_proof_of_possession_configuration)(u,r,t,l)}loginCallbackWithAutoTokensRenewAsync(){return this.loginCallbackWithAutoTokensRenewPromise!==null?this.loginCallbackWithAutoTokensRenewPromise:(this.loginCallbackWithAutoTokensRenewPromise=r_(this),this.loginCallbackWithAutoTokensRenewPromise.finally(()=>{this.loginCallbackWithAutoTokensRenewPromise=null}))}userInfoAsync(e=!1,t=!1){return this.userInfoPromise!==null?this.userInfoPromise:(this.userInfoPromise=t_(this)(e,t),this.userInfoPromise.finally(()=>{this.userInfoPromise=null}))}async renewTokensAsync(e=null,t=null){if(this.renewTokensPromise!==null)return this.renewTokensPromise;if(this.timeoutId)return Br.clearTimeout(this.timeoutId),this.renewTokensPromise=bf(this,!0,e,t),this.renewTokensPromise.finally(()=>{this.renewTokensPromise=null})}async destroyAsync(e){return await Z0(this)(e)}async logoutSameTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ae.logout_from_same_tab,{mmessage:"SessionMonitor",sub:t}))}async logoutOtherTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ae.logout_from_another_tab,{message:"SessionMonitor",sub:t}))}async logoutAsync(e=void 0,t=null){return this.logoutPromise?this.logoutPromise:(this.logoutPromise=e_(this,lr,this.getFetch(),console,this.location)(e,t),this.logoutPromise.finally(()=>{this.logoutPromise=null}))}};Nl.getOrCreate=(n,e)=>(t,r="default")=>n_(n,e)(t,r),Nl.eventNames=ae;let mn=Nl;const Ss=class py{constructor(e){this._oidc=e}subscribeEvents(e){return this._oidc.subscribeEvents(e)}removeEventSubscription(e){this._oidc.removeEventSubscription(e)}publishEvent(e,t){this._oidc.publishEvent(e,t)}static get(e="default"){return new py(mn.get(e))}tryKeepExistingSessionAsync(){return this._oidc.tryKeepExistingSessionAsync()}loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this._oidc.loginAsync(e,t,r,i,s)}logoutAsync(e=void 0,t=null){return this._oidc.logoutAsync(e,t)}silentLoginCallbackAsync(){return this._oidc.silentLoginCallbackAsync()}renewTokensAsync(e=null,t=null){return this._oidc.renewTokensAsync(e,t)}loginCallbackAsync(){return this._oidc.loginCallbackWithAutoTokensRenewAsync()}get tokens(){return this._oidc.tokens}get configuration(){return this._oidc.configuration}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e,t,r,i)}async getValidTokenAsync(e=200,t=50){const r=this._oidc,i={getTokens:()=>r.tokens,configuration:{token_automatic_renew_mode:r.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:r.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:r.renewTokensAsync.bind(r)};return rf(i,e,t)}fetchWithTokens(e,t=!1){return Sf(e,this._oidc,t)}async userInfoAsync(e=!1,t=!1){return this._oidc.userInfoAsync(e,t)}userInfo(){return this._oidc.userInfo}};Ss.getOrCreate=(n,e=new Dr)=>(t,r="default")=>new Ss(mn.getOrCreate(n,e)(t,r)),Ss.eventNames=mn.eventNames;let me=Ss;const xf=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),s_=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),o_=()=>Math.random().toString(36).slice(2,8),l_=(n,e)=>(t,r)=>{if(typeof n.CustomEvent=="function")return new n.CustomEvent(t,r);const i=r||{bubbles:!1,cancelable:!1,detail:void 0},s=e.createEvent("CustomEvent");return s.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),s.prototype=n.Event.prototype,s},a_=(n,e,t)=>({replaceState:(r,i)=>{const s=t(),l=i||n.history.state;n.history.replaceState({key:s,state:l},null,r),n.dispatchEvent(e("popstate"))}}),c_=()=>a_(window,l_(window,document),o_),Ef=()=>Y.jsx("div",{className:"oidc-callback",children:Y.jsxs("div",{className:"oidc-callback__container",children:[Y.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),Y.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),u_=({callBackError:n,callBackSuccess:e,configurationName:t,withCustomHistory:r})=>{const[i,s]=K.useState(!1);K.useEffect(()=>{let u=!0;return(async()=>{const d=me.get;try{const{callbackPath:h}=await d(t).loginCallbackAsync();(r?r():c_()).replaceState(h||"/")}catch(h){u&&(console.warn(h),s(!0))}})(),()=>{u=!1}},[]);const l=n||xf,c=e||Ef;return i?Y.jsx(l,{configurationName:t}):Y.jsx(c,{configurationName:t})},f_=()=>Y.jsx("span",{className:"oidc-loading",children:"Loading"}),d_=()=>Y.jsx("div",{className:"oidc-serviceworker",children:Y.jsxs("div",{className:"oidc-serviceworker__container",children:[Y.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),Y.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),h_=()=>Y.jsx("div",{className:"oidc-session-lost",children:Y.jsxs("div",{className:"oidc-session-lost__container",children:[Y.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),Y.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),p_=({configurationName:n})=>(K.useEffect(()=>{(async()=>{me.get(n).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[n]),null),m_=({configurationName:n})=>{const e=ws(window.location.href),t=me.get,r=t(n);let i=null;for(const[s,l]of Object.entries(e))s==="state"||s==="scope"||(i===null&&(i={}),i[s]=l);return K.useEffect(()=>{r.tokens||r.loginAsync(null,i,!0,e.scope)},[]),Y.jsx(Y.Fragment,{})},g_=({callbackErrorComponent:n,callbackSuccessComponent:e,redirect_uri:t,silent_redirect_uri:r,silent_login_uri:i,children:s,configurationName:l,withCustomHistory:c=null})=>{const u=window?ki(window.location.href):"",[d,h]=K.useState(u);K.useEffect(()=>{const y=()=>h(ki(window.location.href));return y(),window.addEventListener("popstate",y,!1),()=>window.removeEventListener("popstate",y,!1)},[]);const p=ki(t);if(r&&d===ki(r))return Y.jsx(p_,{configurationName:l});if(i&&d===ki(i))return Y.jsx(m_,{configurationName:l});switch(d){case p:return Y.jsx(u_,{callBackError:n,callBackSuccess:e,configurationName:l,withCustomHistory:c});default:return Y.jsx(Y.Fragment,{children:s})}},y_=K.memo(g_),Tf={name:"",data:null},__=({loadingComponent:n,children:e,configurationName:t})=>{const[r,i]=K.useState(!0),s=me.get,l=s(t);return K.useEffect(()=>{let c=!0;return l&&l.tryKeepExistingSessionAsync().then(()=>{c&&i(!1)}),()=>{c=!1}},[t]),Y.jsx(Y.Fragment,{children:r?Y.jsx(n,{configurationName:t}):Y.jsx(Y.Fragment,{children:e})})},xi=({isLoading:n,loadingComponent:e,children:t,configurationName:r})=>{const i=e;return n?Y.jsx(i,{configurationName:r,children:t}):Y.jsx(Y.Fragment,{children:t})},b_=({children:n,configuration:e,configurationName:t="default",callbackSuccessComponent:r=Ef,authenticatingComponent:i=s_,loadingComponent:s=f_,serviceWorkerNotSupportedComponent:l=d_,authenticatingErrorComponent:c=xf,sessionLostComponent:u=h_,onSessionLost:d=null,onLogoutFromAnotherTab:h=null,onLogoutFromSameTab:p=null,withCustomHistory:y=null,onEvent:g=null,getFetch:_=null,location:S=null})=>{const k=(Ke="default")=>me.getOrCreate(_??kf,S??new Dr)(e,Ke),[A,P]=K.useState(!0),[L,B]=K.useState(Tf),[W,z]=K.useState("default");K.useEffect(()=>{const Ke=k(t).subscribeEvents((Me,ft)=>{g&&g(t,Me,ft)});return()=>{k(t).removeEventSubscription(Ke)}},[t,g]),K.useEffect(()=>{const Ke=k(t).subscribeEvents((Me,ft)=>{if(Me===me.eventNames.refreshTokensAsync_error||Me===me.eventNames.syncTokensAsync_error){if(d!=null){d();return}B({name:Me,data:ft})}else if(Me===me.eventNames.logout_from_another_tab){if(h!=null){h();return}B({name:Me,data:ft})}else Me===me.eventNames.logout_from_same_tab?p!=null&&p():Me===me.eventNames.loginAsync_begin||Me===me.eventNames.loginCallbackAsync_end||Me===me.eventNames.loginAsync_error||Me===me.eventNames.loginCallbackAsync_error?B({name:Me,data:ft}):Me===me.eventNames.service_worker_not_supported_by_browser&&e.service_worker_only===!0&&B({name:Me,data:ft})});return z(t),P(!1),()=>{k(t).removeEventSubscription(Ke),B(Tf)}},[e,t]);const J=u,j=i,V=s,ne=l,ve=c,Le=A||W!==t,_t=k(t);switch(L.name){case me.eventNames.service_worker_not_supported_by_browser:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(ne,{configurationName:t})});case me.eventNames.loginAsync_begin:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(j,{configurationName:t})});case me.eventNames.loginAsync_error:case me.eventNames.loginCallbackAsync_error:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(ve,{configurationName:t})});case me.eventNames.refreshTokensAsync_error:case me.eventNames.syncTokensAsync_error:case me.eventNames.logout_from_another_tab:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(J,{configurationName:t})});default:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(y_,{redirect_uri:_t.configuration.redirect_uri,silent_redirect_uri:_t.configuration.silent_redirect_uri,silent_login_uri:_t.configuration.silent_login_uri,callbackSuccessComponent:r,callbackErrorComponent:c,authenticatingComponent:i,configurationName:t,withCustomHistory:y,location:S??new Dr,children:Y.jsx(__,{loadingComponent:V,configurationName:t,children:n})})})}},Of="default",Il=(n,e)=>{let t=!1;return n(e)&&(t=n(e).tokens!=null),t},v_=(n=Of)=>{const e=me.get,[t,r]=K.useState(Il(e,n));return K.useEffect(()=>{let i=!0;const s=e(n);r(Il(e,n));const l=s.subscribeEvents((c,u)=>{(c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.token_acquired)&&i&&r(Il(e,n))});return()=>{i=!1,s.removeEventSubscription(l)}},[n]),{login:(i=void 0,s=void 0,l=!1,c=void 0)=>e(n).loginAsync(i,s,!1,c,l),logout:(i=void 0,s=void 0)=>e(n).logoutAsync(i,s),renewTokens:async(i=void 0)=>{const s=await e(n).renewTokensAsync(i);return{accessToken:s.accessToken,accessTokenPayload:s.accessTokenPayload,idToken:s.idToken,idTokenPayload:s.idTokenPayload}},isAuthenticated:t}},Af={accessToken:null,accessTokenPayload:null},w_=n=>{const e=me.get,t=e(n);if(t.tokens){const r=t.tokens;return{accessToken:r.accessToken,accessTokenPayload:r.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:t.configuration.demonstrating_proof_of_possession?(i,s)=>t.generateDemonstrationOfProofOfPossessionAsync(r.accessToken,i,s):null}}return Af};function S_(n,e){return n.configuration.demonstrating_proof_of_possession?(t,r,i={})=>n.generateDemonstrationOfProofOfPossessionAsync(e.accessToken,t,r,i):null}const k_=(n=Of)=>{const e=me.get,[t,r]=K.useState(w_(n));return K.useEffect(()=>{let i=!0;const s=e(n);if(s.tokens){const c=s.tokens;r({accessToken:c.accessToken,accessTokenPayload:c.accessTokenPayload})}const l=s.subscribeEvents((c,u)=>{if((c===me.eventNames.token_renewed||c===me.eventNames.token_acquired||c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.refreshTokensAsync_error||c===me.eventNames.syncTokensAsync_error)&&i){const d=s.tokens;r(d!=null?{accessToken:d.accessToken,accessTokenPayload:d.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:S_(s,d)}:Af)}});return()=>{i=!1,s.removeEventSubscription(l)}},[n]),t},x_=Pr.graphql(`
23
+ <%s key={someKey} {...props} />`,je,Ne,Ft,Ne),uo[Ne+je]=!0)}if(Ne=null,Ee!==void 0&&(t(Ee),Ne=""+Ee),l(te)&&(t(te.key),Ne=""+te.key),"key"in te){Ee={};for(var Ki in te)Ki!=="key"&&(Ee[Ki]=te[Ki])}else Ee=te;return Ne&&c(Ee,typeof F=="function"?F.displayName||F.name||"Unknown":F),d(F,Ne,Xe,cn,i(),Ee,Gn,Ui)}function p(F){typeof F=="object"&&F!==null&&F.$$typeof===g&&F._store&&(F._store.validated=1)}var y=K,g=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ve=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Le=Object.prototype.hasOwnProperty,_t=Array.isArray,Ke=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(F){return F()}};var Me,ft={},Gt=y["react-stack-bottom-frame"].bind(y,s)(),wn=Ke(r(s)),uo={};_i.Fragment=S,_i.jsx=function(F,te,Ee,je,cn){var Xe=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,Ee,!1,je,cn,Xe?Error("react-stack-top-frame"):Gt,Xe?Ke(r(F)):wn)},_i.jsxs=function(F,te,Ee,je,cn){var Xe=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,Ee,!0,je,cn,Xe?Error("react-stack-top-frame"):Gt,Xe?Ke(r(F)):wn)}}()),_i}process.env.NODE_ENV==="production"?vl.exports=f0():vl.exports=d0();var Y=vl.exports;let Dr=class{open(e){window.location.href=e}reload(){window.location.reload()}getCurrentHref(){return window.location.href}getPath(){const e=window.location;return e.pathname+(e.search||"")+(e.hash||"")}getOrigin(){return window.origin}};const ef=2e3,Lr=console;let h0=class{constructor(e,t,r,i=ef,s=!0){this._callback=e,this._client_id=t,this._url=r,this._interval=i||ef,this._stopOnError=s;const l=r.indexOf("/",r.indexOf("//")+2);this._frame_origin=r.substring(0,l),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=r}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1)})}_message(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&(e.data==="error"?(Lr.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):e.data==="changed"?(Lr.debug(e),Lr.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):Lr.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))}start(e){Lr.debug("CheckSessionIFrame.start :"+e),this.stop();const t=()=>{this._frame.contentWindow.postMessage(this._client_id+" "+e,this._frame_origin)};t(),this._timer=window.setInterval(t,this._interval)}stop(){this._timer&&(Lr.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)}};const ae={service_worker_not_supported_by_browser:"service_worker_not_supported_by_browser",token_acquired:"token_acquired",logout_from_another_tab:"logout_from_another_tab",logout_from_same_tab:"logout_from_same_tab",token_renewed:"token_renewed",token_timer:"token_timer",loginAsync_begin:"loginAsync_begin",loginAsync_error:"loginAsync_error",loginCallbackAsync_begin:"loginCallbackAsync_begin",loginCallbackAsync_end:"loginCallbackAsync_end",loginCallbackAsync_error:"loginCallbackAsync_error",refreshTokensAsync_begin:"refreshTokensAsync_begin",refreshTokensAsync:"refreshTokensAsync",refreshTokensAsync_end:"refreshTokensAsync_end",refreshTokensAsync_error:"refreshTokensAsync_error",refreshTokensAsync_silent_error:"refreshTokensAsync_silent_error",tryKeepExistingSessionAsync_begin:"tryKeepExistingSessionAsync_begin",tryKeepExistingSessionAsync_end:"tryKeepExistingSessionAsync_end",tryKeepExistingSessionAsync_error:"tryKeepExistingSessionAsync_error",silentLoginAsync_begin:"silentLoginAsync_begin",silentLoginAsync:"silentLoginAsync",silentLoginAsync_end:"silentLoginAsync_end",silentLoginAsync_error:"silentLoginAsync_error",syncTokensAsync_begin:"syncTokensAsync_begin",syncTokensAsync_lock_not_available:"syncTokensAsync_lock_not_available",syncTokensAsync_end:"syncTokensAsync_end",syncTokensAsync_error:"syncTokensAsync_error",tokensInvalidAndWaitingActionsToRefresh:"tokensInvalidAndWaitingActionsToRefresh"},Nt=(n,e=sessionStorage)=>{const t=S=>(e[`oidc.${n}`]=JSON.stringify({tokens:null,status:S}),Promise.resolve()),r=async()=>{if(!e[`oidc.${n}`])return e[`oidc.${n}`]=JSON.stringify({tokens:null,status:null}),{tokens:null,status:null};const S=JSON.parse(e[`oidc.${n}`]);return Promise.resolve({tokens:S.tokens,status:S.status})},i=S=>{e[`oidc.${n}`]=JSON.stringify({tokens:S})},s=async S=>{e[`oidc.session_state.${n}`]=S},l=async()=>e[`oidc.session_state.${n}`],c=S=>{e[`oidc.nonce.${n}`]=S.nonce},u=S=>{e[`oidc.jwk.${n}`]=JSON.stringify(S)},d=()=>JSON.parse(e[`oidc.jwk.${n}`]),h=async()=>({nonce:e[`oidc.nonce.${n}`]}),p=async S=>{e[`oidc.dpop_nonce.${n}`]=S},y=()=>e[`oidc.dpop_nonce.${n}`],g=()=>e[`oidc.${n}`]?JSON.stringify({tokens:JSON.parse(e[`oidc.${n}`]).tokens}):null,_={};return{clearAsync:t,initAsync:r,setTokens:i,getTokens:g,setSessionStateAsync:s,getSessionStateAsync:l,setNonceAsync:c,getNonceAsync:h,setLoginParams:S=>{_[n]=S,e[`oidc.login.${n}`]=JSON.stringify(S)},getLoginParams:()=>{const S=e[`oidc.login.${n}`];return S?(_[n]||(_[n]=JSON.parse(S)),_[n]):(console.warn(`storage[oidc.login.${n}] is empty, you should have an bad OIDC or code configuration somewhere.`),null)},getStateAsync:async()=>e[`oidc.state.${n}`],setStateAsync:async S=>{e[`oidc.state.${n}`]=S},getCodeVerifierAsync:async()=>e[`oidc.code_verifier.${n}`],setCodeVerifierAsync:async S=>{e[`oidc.code_verifier.${n}`]=S},setDemonstratingProofOfPossessionNonce:p,getDemonstratingProofOfPossessionNonce:y,setDemonstratingProofOfPossessionJwkAsync:u,getDemonstratingProofOfPossessionJwkAsync:d}};var bi=(n=>(n.AutomaticBeforeTokenExpiration="AutomaticBeforeTokensExpiration",n.AutomaticOnlyWhenFetchExecuted="AutomaticOnlyWhenFetchExecuted",n))(bi||{});const p0=n=>decodeURIComponent(Array.prototype.map.call(atob(n),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),m0=n=>JSON.parse(p0(n.replaceAll(/-/g,"+").replaceAll(/_/g,"/"))),tf=n=>{try{return n&&g0(n,".")===2?m0(n.split(".")[1]):null}catch(e){console.warn(e)}return null},g0=(n,e)=>n.split(e).length-1,wl={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"};function y0(n,e,t){if(n.issuedAt){if(typeof n.issuedAt=="string")return parseInt(n.issuedAt,10)}else return e&&e.iat?e.iat:t&&t.iat?t.iat:new Date().getTime()/1e3;return n.issuedAt}const Sl=(n,e=null,t)=>{if(!n)return null;let r;const i=typeof n.expiresIn=="string"?parseInt(n.expiresIn,10):n.expiresIn;n.accessTokenPayload!==void 0?r=n.accessTokenPayload:r=tf(n.accessToken);let s;e!=null&&"idToken"in e&&!("idToken"in n)?s=e.idToken:s=n.idToken;const l=n.idTokenPayload?n.idTokenPayload:tf(s),c=l&&l.exp?l.exp:Number.MAX_VALUE,u=r&&r.exp?r.exp:n.issuedAt+i;n.issuedAt=y0(n,r,l);let d;n.expiresAt?d=n.expiresAt:t===wl.access_token_invalid?d=u:t===wl.id_token_invalid?d=c:d=c<u?c:u;const h={...n,idTokenPayload:l,accessTokenPayload:r,expiresAt:d,idToken:s};if(e!=null&&"refreshToken"in e&&!("refreshToken"in n)){const p=e.refreshToken;return{...h,refreshToken:p}}return h},kl=(n,e,t)=>{if(!n)return null;if(!n.issued_at){const i=new Date().getTime()/1e3;n.issued_at=i}const r={accessToken:n.access_token,expiresIn:n.expires_in,idToken:n.id_token,scope:n.scope,tokenType:n.token_type,issuedAt:n.issued_at};return"refresh_token"in n&&(r.refreshToken=n.refresh_token),n.accessTokenPayload!==void 0&&(r.accessTokenPayload=n.accessTokenPayload),n.idTokenPayload!==void 0&&(r.idTokenPayload=n.idTokenPayload),Sl(r,e,t)},vi=(n,e)=>{const t=new Date().getTime()/1e3,r=e-t;return Math.round(r-n)},nf=(n,e=0)=>n?vi(e,n.expiresAt)>0:!1,rf=async(n,e=200,t=50)=>{let r=t;if(!n.getTokens())return null;for(;!nf(n.getTokens(),n.configuration.refresh_time_before_tokens_expiration_in_second)&&r>0;){if(n.configuration.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted){await n.renewTokensAsync({});break}else await _s({milliseconds:e});r=r-1}return{isTokensValid:nf(n.getTokens()),tokens:n.getTokens(),numberWaited:r-t}},sf=(n,e,t)=>{if(n.idTokenPayload){const r=n.idTokenPayload;if(t.issuer!==r.iss)return{isValid:!1,reason:`Issuer does not match (oidcServerConfiguration issuer) ${t.issuer} !== (idTokenPayload issuer) ${r.iss}`};const i=new Date().getTime()/1e3;if(r.exp&&r.exp<i)return{isValid:!1,reason:`Token expired (idTokenPayload exp) ${r.exp} < (currentTimeUnixSecond) ${i}`};const s=60*60*24*7;if(r.iat&&r.iat+s<i)return{isValid:!1,reason:`Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${r.iat+s} < (currentTimeUnixSecond) ${i}`};if(r.nonce&&r.nonce!==e)return{isValid:!1,reason:`Nonce does not match (idTokenPayload nonce) ${r.nonce} !== (nonce) ${e}`}}return{isValid:!0,reason:""}},Br=function(){const n=typeof window>"u"?global:window;return{setTimeout:setTimeout.bind(n),clearTimeout:clearTimeout.bind(n),setInterval:setInterval.bind(n),clearInterval:clearInterval.bind(n)}}(),of="7.25.7";let lf=null,ys;const _s=({milliseconds:n})=>new Promise(e=>Br.setTimeout(e,n)),af=(n="/")=>{try{ys=new AbortController,fetch(`${n}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,{signal:ys.signal}).catch(e=>{console.log(e)}),_s({milliseconds:150*1e3}).then(af)}catch(e){console.log(e)}},cf=()=>{ys&&ys.abort()},_0=(n="/")=>fetch(`${n}OidcKeepAliveServiceWorker.json`,{headers:{"oidc-vanilla":"true"}}).then(e=>e.statusText==="oidc-service-worker").catch(e=>{console.log(e)}),b0=n=>async(e,t)=>{t(),await e.update();const r=await e.unregister();console.log(`Service worker unregistration ${r?"successful":"failed"}`),await _s({milliseconds:2e3}),n.reload()},uf=n=>{const e=sessionStorage.getItem(`oidc.tabId.${n}`);if(e)return e;const t=globalThis.crypto.randomUUID();return sessionStorage.setItem(`oidc.tabId.${n}`,t),t},lt=n=>e=>new Promise(function(t,r){const i=new MessageChannel;i.port1.onmessage=function(s){s!=null&&s.data.error?r(s.data.error):t(s.data),i.port1.close(),i.port2.close()},n.active.postMessage({...e,tabId:uf(e.configurationName)},[i.port2])}),It=async(n,e)=>{var t;const r=n.service_worker_relative_url;if(typeof window>"u"||typeof navigator>"u"||!navigator.serviceWorker||!r||n.service_worker_activate()===!1)return null;let i=null;n.service_worker_register?i=await n.service_worker_register(r):(i=await navigator.serviceWorker.register(r),i.active&&i.waiting&&(console.log("Detected new service worker waiting, unregistering and reloading"),await((t=n.service_worker_update_require_callback)==null?void 0:t.call(n,i,cf))));try{await navigator.serviceWorker.ready,navigator.serviceWorker.controller||await lt(i)({type:"claim"})}catch(g){return console.warn(`Failed init ServiceWorker ${g.toString()}`),null}const s=async g=>lt(i)({type:"clear",data:{status:g},configurationName:e}),l=async(g,_,S)=>{var k;const A=await lt(i)({type:"init",data:{oidcServerConfiguration:g,where:_,oidcConfiguration:{token_renew_mode:S.token_renew_mode,service_worker_convert_all_requests_to_cors:S.service_worker_convert_all_requests_to_cors}},configurationName:e}),P=A.version;return P!==of&&(console.warn(`Service worker ${P} version mismatch with js client version ${of}, unregistering and reloading`),await((k=S.service_worker_update_require_callback)==null?void 0:k.call(S,i,cf))),{tokens:kl(A.tokens,null,S.token_renew_mode),status:A.status}},c=(g="/")=>{lf==null&&(lf="not_null",af(g))},u=g=>lt(i)({type:"setSessionState",data:{sessionState:g},configurationName:e}),d=async()=>(await lt(i)({type:"getSessionState",data:null,configurationName:e})).sessionState,h=g=>(sessionStorage[`oidc.nonce.${e}`]=g.nonce,lt(i)({type:"setNonce",data:{nonce:g},configurationName:e})),p=async()=>{let g=(await lt(i)({type:"getNonce",data:null,configurationName:e})).nonce;return g||(g=sessionStorage[`oidc.nonce.${e}`],console.warn("nonce not found in service worker, using sessionStorage")),{nonce:g}},y={};return{clearAsync:s,initAsync:l,startKeepAliveServiceWorker:()=>c(n.service_worker_keep_alive_path),isServiceWorkerProxyActiveAsync:()=>_0(n.service_worker_keep_alive_path),setSessionStateAsync:u,getSessionStateAsync:d,setNonceAsync:h,getNonceAsync:p,setLoginParams:g=>{y[e]=g,localStorage[`oidc.login.${e}`]=JSON.stringify(g)},getLoginParams:()=>{const g=localStorage[`oidc.login.${e}`];return y[e]||(y[e]=JSON.parse(g)),y[e]},getStateAsync:async()=>{let g=(await lt(i)({type:"getState",data:null,configurationName:e})).state;return g||(g=sessionStorage[`oidc.state.${e}`],console.warn("state not found in service worker, using sessionStorage")),g},setStateAsync:async g=>(sessionStorage[`oidc.state.${e}`]=g,lt(i)({type:"setState",data:{state:g},configurationName:e})),getCodeVerifierAsync:async()=>{let g=(await lt(i)({type:"getCodeVerifier",data:null,configurationName:e})).codeVerifier;return g||(g=sessionStorage[`oidc.code_verifier.${e}`],console.warn("codeVerifier not found in service worker, using sessionStorage")),g},setCodeVerifierAsync:async g=>(sessionStorage[`oidc.code_verifier.${e}`]=g,lt(i)({type:"setCodeVerifier",data:{codeVerifier:g},configurationName:e})),setDemonstratingProofOfPossessionNonce:async g=>{await lt(i)({type:"setDemonstratingProofOfPossessionNonce",data:{demonstratingProofOfPossessionNonce:g},configurationName:e})},getDemonstratingProofOfPossessionNonce:async()=>(await lt(i)({type:"getDemonstratingProofOfPossessionNonce",data:null,configurationName:e})).demonstratingProofOfPossessionNonce,setDemonstratingProofOfPossessionJwkAsync:async g=>{const _=JSON.stringify(g);await lt(i)({type:"setDemonstratingProofOfPossessionJwk",data:{demonstratingProofOfPossessionJwkJson:_},configurationName:e})},getDemonstratingProofOfPossessionJwkAsync:async()=>{const g=await lt(i)({type:"getDemonstratingProofOfPossessionJwk",data:null,configurationName:e});return g.demonstratingProofOfPossessionJwkJson?JSON.parse(g.demonstratingProofOfPossessionJwkJson):null}}},Fr={},v0=(n,e=window.sessionStorage,t)=>{if(!Fr[n]&&e){const i=e.getItem(n);i&&(Fr[n]=JSON.parse(i))}const r=1e3*t;return Fr[n]&&Fr[n].timestamp+r>Date.now()?Fr[n].result:null},w0=(n,e,t=window.sessionStorage)=>{const r=Date.now();Fr[n]={result:e,timestamp:r},t&&t.setItem(n,JSON.stringify({result:e,timestamp:r}))};function ff(n){return new TextEncoder().encode(n)}function df(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function S0(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}const xl=n=>{let e="";return n.forEach(function(t){e+=String.fromCharCode(t)}),df(e)};function hf(n){return df(S0(n))}const k0={importKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256",hash:{name:"ES256"}},signAlgorithm:{name:"ECDSA",hash:{name:"SHA-256"}},generateKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256"},digestAlgorithm:{name:"SHA-256"},jwtHeaderAlgorithm:"ES256"},x0=n=>async(e,t,r,i,s="dpop+jwt")=>{switch(e=Object.assign({},e),t.typ=s,t.alg=i.jwtHeaderAlgorithm,t.alg){case"ES256":t.jwk={kty:e.kty,crv:e.crv,x:e.x,y:e.y};break;case"RS256":t.jwk={kty:e.kty,n:e.n,e:e.e,kid:t.kid};break;default:throw new Error("Unknown or not implemented JWS algorithm")}const l={protected:hf(JSON.stringify(t)),payload:hf(JSON.stringify(r))},c=i.importKeyAlgorithm,u=!0,d=["sign"],h=await n.crypto.subtle.importKey("jwk",e,c,u,d),p=ff(`${l.protected}.${l.payload}`),y=i.signAlgorithm,g=await n.crypto.subtle.sign(y,h,p);return l.signature=xl(new Uint8Array(g)),`${l.protected}.${l.payload}.${l.signature}`},E0={sign:x0},T0=n=>async e=>{const t=e,r=!0,i=["sign","verify"],s=await n.crypto.subtle.generateKey(t,r,i);return await n.crypto.subtle.exportKey("jwk",s.privateKey)},O0=n=>{const e=Object.assign({},n);return delete e.d,e.key_ops=["verify"],e},A0={generate:T0,neuter:O0},C0=n=>async(e,t)=>{let r;switch(e.kty){case"EC":r='{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",e.crv).replace("X",e.x).replace("Y",e.y);break;case"RSA":r='{"e":"E","kty":"RSA","n":"N"}'.replace("E",e.e).replace("N",e.n);break;default:throw new Error("Unknown or not implemented JWK type")}const i=await n.crypto.subtle.digest(t,ff(r));return xl(new Uint8Array(i))},M0={thumbprint:C0},N0=n=>async e=>await A0.generate(n)(e),pf=n=>e=>async(t,r="POST",i,s={})=>{const l={jti:btoa(I0()),htm:r,htu:i,iat:Math.round(Date.now()/1e3),...s},c=await M0.thumbprint(n)(t,e.digestAlgorithm);return await E0.sign(n)(t,{kid:c},l,e)},I0=()=>{const n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",e="0123456789abcdef";let t=0,r="";for(let i=0;i<36;i++)n[i]!=="-"&&n[i]!=="4"&&(t=Math.random()*16|0),n[i]==="x"?r+=e[t]:n[i]==="y"?(t&=3,t|=8,r+=e[t]):r+=n[i];return r},mf=()=>{const n=typeof window<"u"&&!!window.crypto,e=n&&!!window.crypto.subtle;return{hasCrypto:n,hasSubtleCrypto:e}},El="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",P0=n=>{const e=[];for(let t=0;t<n.byteLength;t+=1){const r=n[t]%El.length;e.push(El[r])}return e.join("")},Tl=n=>{const e=new Uint8Array(n),{hasCrypto:t}=mf();if(t)window.crypto.getRandomValues(e);else for(let r=0;r<n;r+=1)e[r]=Math.random()*El.length|0;return P0(e)};function R0(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return t}function gf(n){return new Promise((e,t)=>{crypto.subtle.digest("SHA-256",R0(n)).then(r=>e(xl(new Uint8Array(r))),r=>t(r))})}const D0=n=>{if(n.length<43||n.length>128)return Promise.reject(new Error("Invalid code length."));const{hasSubtleCrypto:e}=mf();return e?gf(n):Promise.reject(new Error("window.crypto.subtle is unavailable."))},L0=60*60,B0=n=>async(e,t=L0,r=window.sessionStorage,i=1e4)=>{const s=`${e}/.well-known/openid-configuration`,l=`oidc.server:${e}`,c=v0(l,r,t);if(c)return new Ml(c);const u=await wi(n)(s,{},i);if(u.status!==200)return null;const d=await u.json();return w0(l,d,r),new Ml(d)},wi=n=>async(e,t={},r=1e4,i=0)=>{let s;try{const l=new AbortController;setTimeout(()=>l.abort(),r),s=await n(e,{...t,signal:l.signal})}catch(l){if(l.name==="AbortError"||l.message==="Network request failed"){if(i<=1)return await wi(n)(e,t,r,i+1);throw l}else throw console.error(l.message),l}return s},Ol={refresh_token:"refresh_token",access_token:"access_token"},yf=n=>async(e,t,r=Ol.refresh_token,i,s={},l=1e4)=>{const c={token:t,token_type_hint:r,client_id:i};for(const[h,p]of Object.entries(s))c[h]===void 0&&(c[h]=p);const u=[];for(const h in c){const p=encodeURIComponent(h),y=encodeURIComponent(c[h]);u.push(`${p}=${y}`)}const d=u.join("&");return(await wi(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:d},l)).status!==200?{success:!1}:{success:!0}},F0=n=>async(e,t,r,i,s={},l,c=1e4)=>{for(const[g,_]of Object.entries(r))t[g]===void 0&&(t[g]=_);const u=[];for(const g in t){const _=encodeURIComponent(g),S=encodeURIComponent(t[g]);u.push(`${_}=${S}`)}const d=u.join("&"),h=await wi(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...s},body:d},c);if(h.status!==200)return{success:!1,status:h.status,demonstratingProofOfPossessionNonce:null};const p=await h.json();let y=null;return h.headers.has(bs)&&(y=h.headers.get(bs)),{success:!0,status:h.status,data:kl(p,i,l),demonstratingProofOfPossessionNonce:y}},z0=(n,e)=>async(t,r)=>{r=r?{...r}:{};const i=Tl(128),s=await D0(i);await n.setCodeVerifierAsync(i),await n.setStateAsync(r.state),r.code_challenge=s,r.code_challenge_method="S256";let l="";if(r)for(const[c,u]of Object.entries(r))l===""?l+="?":l+="&",l+=`${c}=${encodeURIComponent(u)}`;e.open(`${t}${l}`)},bs="DPoP-Nonce",W0=n=>async(e,t,r,i,s=1e4)=>{t=t?{...t}:{},t.code_verifier=await n.getCodeVerifierAsync();const l=[];for(const p in t){const y=encodeURIComponent(p),g=encodeURIComponent(t[p]);l.push(`${y}=${g}`)}const c=l.join("&"),u=await wi(fetch)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...r},body:c},s);if(await Promise.all([n.setCodeVerifierAsync(null),n.setStateAsync(null)]),u.status!==200)return{success:!1,status:u.status};let d=null;u.headers.has(bs)&&(d=u.headers.get(bs));const h=await u.json();return{success:!0,data:{state:t.state,tokens:kl(h,null,i),demonstratingProofOfPossessionNonce:d}}};async function _f(n,e,t,r=null){const i=c=>{n.tokens=c},{tokens:s,status:l}=await vs(n)(i,0,e,t,r);return await It(n.configuration,n.configurationName)||await Nt(n.configurationName,n.configuration.storage).setTokens(n.tokens),n.tokens?s:(await n.destroyAsync(l),null)}async function bf(n,e=!1,t=null,r=null){const i=n.configuration,s=`${i.client_id}_${n.configurationName}_${i.authority}`;let l;const c=await It(n.configuration,n.configurationName);if((i==null?void 0:i.storage)===(window==null?void 0:window.sessionStorage)&&!c||!navigator.locks)l=await _f(n,e,t,r);else{let u="retry";for(;u==="retry";)u=await navigator.locks.request(s,{ifAvailable:!0},async d=>d?await _f(n,e,t,r):(n.publishEvent(mn.eventNames.syncTokensAsync_lock_not_available,{lock:"lock not available"}),"retry"));l=u}return l?(n.timeoutId&&(n.timeoutId=Si(n,n.tokens.expiresAt,t,r)),n.tokens):null}const Si=(n,e,t=null,r=null)=>{const i=n.configuration.refresh_time_before_tokens_expiration_in_second;return n.timeoutId&&Br.clearTimeout(n.timeoutId),Br.setTimeout(async()=>{const s={timeLeft:vi(i,e)};n.publishEvent(mn.eventNames.token_timer,s),await bf(n,!1,t,r)},1e3)},In={FORCE_REFRESH:"FORCE_REFRESH",SESSION_LOST:"SESSION_LOST",NOT_CONNECTED:"NOT_CONNECTED",TOKENS_VALID:"TOKENS_VALID",TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",LOGOUT_FROM_ANOTHER_TAB:"LOGOUT_FROM_ANOTHER_TAB",REQUIRE_SYNC_TOKENS:"REQUIRE_SYNC_TOKENS"},$0=n=>async(e,t,r,i=!1)=>{const s={nonce:null};if(!r)return{tokens:null,status:"NOT_CONNECTED",nonce:s};let l=s;const c=await n.initAsync(e.authority,e.authority_configuration),u=await It(e,t);if(u){const{status:h,tokens:p}=await u.initAsync(c,"syncTokensAsync",e);if(h==="LOGGED_OUT")return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};if(h==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(!h||!p)return{tokens:null,status:"REQUIRE_SYNC_TOKENS",nonce:s};if(p.issuedAt!==r.issuedAt){const y=vi(e.refresh_time_before_tokens_expiration_in_second,p.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",g=await u.getNonceAsync();return{tokens:p,status:y,nonce:g}}l=await u.getNonceAsync()}else{const h=Nt(t,e.storage??sessionStorage),p=await h.initAsync();let{tokens:y}=p;const{status:g}=p;if(y&&(y=Sl(y,n.tokens,e.token_renew_mode)),y){if(g==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(y.issuedAt!==r.issuedAt){const _=vi(e.refresh_time_before_tokens_expiration_in_second,y.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",S=await h.getNonceAsync();return{tokens:y,status:_,nonce:S}}}else return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};l=await h.getNonceAsync()}const d=vi(e.refresh_time_before_tokens_expiration_in_second,r.expiresAt)>0?"TOKENS_VALID":"TOKENS_INVALID";return i?{tokens:r,status:"FORCE_REFRESH",nonce:l}:{tokens:r,status:d,nonce:l}},vs=n=>async(e,t=0,r=!1,i=null,s=null)=>{if(!navigator.onLine&&document.hidden)return{tokens:n.tokens,status:"GIVE_UP"};let l=6;for(;!navigator.onLine&&l>0;)await _s({milliseconds:1e3}),l--,n.publishEvent(ae.refreshTokensAsync,{message:`wait because navigator is offline try ${l}`});const c=document.hidden,u=c?t:t+1;if(t>4)return c?{tokens:n.tokens,status:"GIVE_UP"}:(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token"}),{tokens:null,status:"SESSION_LOST"});i||(i={});const d=n.configuration,h=(y,g=null,_=null)=>Al(n.configurationName,n.configuration,n.publishEvent.bind(n))(y,g,_),p=async()=>{try{let y;const g=await It(d,n.configurationName);g?y=g.getLoginParams():y=Nt(n.configurationName,d.storage).getLoginParams();const _=await h({...y.extras,...i,prompt:"none",scope:s});return _?_.error?(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token silent"}),{tokens:null,status:"SESSION_LOST"}):(e(_.tokens),n.publishEvent(mn.eventNames.token_renewed,{}),{tokens:_.tokens,status:"LOGGED"}):(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token silent not active"}),{tokens:null,status:"SESSION_LOST"})}catch(y){return console.error(y),n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"exceptionSilent",exception:y.message}),await vs(n)(e,u,r,i,s)}};try{const{status:y,tokens:g,nonce:_}=await $0(n)(d,n.configurationName,n.tokens,r);switch(y){case In.SESSION_LOST:return e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:"refresh token session lost"}),{tokens:null,status:"SESSION_LOST"};case In.NOT_CONNECTED:return e(null),{tokens:null,status:null};case In.TOKENS_VALID:return e(g),{tokens:g,status:"LOGGED_IN"};case In.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:return e(g),n.publishEvent(mn.eventNames.token_renewed,{reason:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"}),{tokens:g,status:"LOGGED_IN"};case In.LOGOUT_FROM_ANOTHER_TAB:return e(null),n.publishEvent(ae.logout_from_another_tab,{status:"session syncTokensAsync"}),{tokens:null,status:"LOGGED_OUT"};case In.REQUIRE_SYNC_TOKENS:return d.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted&&In.FORCE_REFRESH!==y?(n.publishEvent(ae.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"}):(n.publishEvent(ae.refreshTokensAsync_begin,{tryNumber:t}),await p());default:{if(d.token_automatic_renew_mode==bi.AutomaticOnlyWhenFetchExecuted&&In.FORCE_REFRESH!==y)return n.publishEvent(ae.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"};if(n.publishEvent(ae.refreshTokensAsync_begin,{refreshToken:g.refreshToken,status:y,tryNumber:t}),!g.refreshToken)return await p();const S=d.client_id,k=d.redirect_uri,A=d.authority,P={...d.token_request_extras?d.token_request_extras:{}};for(const[L,B]of Object.entries(i))L.endsWith(":token_request")&&(P[L.replace(":token_request","")]=B);return await(async()=>{const L={client_id:S,redirect_uri:k,grant_type:"refresh_token",refresh_token:g.refreshToken},B=await n.initAsync(A,d.authority_configuration),W=document.hidden?1e4:3e4*10,z=B.tokenEndpoint,J={};d.demonstrating_proof_of_possession&&(J.DPoP=await n.generateDemonstrationOfProofOfPossessionAsync(g.accessToken,z,"POST"));const j=await F0(n.getFetch())(z,L,P,g,J,d.token_renew_mode,W);if(j.success){const{isValid:V,reason:ne}=sf(j.data,_.nonce,B);if(!V)return e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:`refresh token return not valid tokens, reason: ${ne}`}),{tokens:null,status:"SESSION_LOST"};if(e(j.data),j.demonstratingProofOfPossessionNonce){const ve=await It(d,n.configurationName);ve?await ve.setDemonstratingProofOfPossessionNonce(j.demonstratingProofOfPossessionNonce):await Nt(n.configurationName,d.storage).setDemonstratingProofOfPossessionNonce(j.demonstratingProofOfPossessionNonce)}return n.publishEvent(ae.refreshTokensAsync_end,{success:j.success}),n.publishEvent(mn.eventNames.token_renewed,{reason:"REFRESH_TOKEN"}),{tokens:j.data,status:"LOGGED_IN"}}else return n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"bad request",tokenResponse:j}),j.status>=400&&j.status<500?(e(null),n.publishEvent(ae.refreshTokensAsync_error,{message:`session lost: ${j.status}`}),{tokens:null,status:"SESSION_LOST"}):await vs(n)(e,u,r,i,s)})()}}}catch(y){return console.error(y),n.publishEvent(ae.refreshTokensAsync_silent_error,{message:"exception",exception:y.message}),new Promise((g,_)=>{setTimeout(()=>{vs(n)(e,u,r,i,s).then(g).catch(_)},1e3)})}},Al=(n,e,t)=>(r=null,i=null,s=null)=>{if(!e.silent_redirect_uri||!e.silent_login_uri)return Promise.resolve(null);try{t(ae.silentLoginAsync_begin,{});let l="";if(i&&(r==null&&(r={}),r.state=i),s!=null&&(r==null&&(r={}),r.scope=s),r!=null)for(const[p,y]of Object.entries(r))l===""?l=`?${encodeURIComponent(p)}=${encodeURIComponent(y)}`:l+=`&${encodeURIComponent(p)}=${encodeURIComponent(y)}`;const c=e.silent_login_uri+l,u=c.indexOf("/",c.indexOf("//")+2),d=c.substring(0,u),h=document.createElement("iframe");return h.width="0px",h.height="0px",h.id=`${n}_oidc_iframe`,h.setAttribute("src",c),document.body.appendChild(h),new Promise((p,y)=>{let g=!1;const _=()=>{window.removeEventListener("message",S),h.remove(),g=!0},S=k=>{if(k.origin===d&&k.source===h.contentWindow){const A=`${n}_oidc_tokens:`,P=`${n}_oidc_error:`,L=`${n}_oidc_exception:`,B=k.data;if(B&&typeof B=="string"&&!g){if(B.startsWith(A)){const W=JSON.parse(k.data.replace(A,""));t(ae.silentLoginAsync_end,{}),p(W),_()}else if(B.startsWith(P)){const W=JSON.parse(k.data.replace(P,""));t(ae.silentLoginAsync_error,W),p({error:"oidc_"+W.error,tokens:null,sessionState:null}),_()}else if(B.startsWith(L)){const W=JSON.parse(k.data.replace(L,""));t(ae.silentLoginAsync_error,W),y(new Error(W.error)),_()}}}};try{window.addEventListener("message",S);const k=e.silent_login_timeout;setTimeout(()=>{g||(_(),t(ae.silentLoginAsync_error,{reason:"timeout"}),y(new Error("timeout")))},k)}catch(k){_(),t(ae.silentLoginAsync_error,k),y(k)}})}catch(l){throw t(ae.silentLoginAsync_error,l),l}},V0=(n,e,t,r,i)=>(s=null,l=void 0)=>{s={...s};const c=(u,d,h)=>Al(e,t,r.bind(i))(u,d,h);return(async()=>{i.timeoutId&&Br.clearTimeout(i.timeoutId);let u;s&&"state"in s&&(u=s.state,delete s.state);try{const d=t.extras?{...t.extras,...s}:s,h=await c({...d,prompt:"none"},u,l);if(h)return i.tokens=h.tokens,r(ae.token_acquired,{}),i.timeoutId=Si(i,i.tokens.expiresAt,s,l),{}}catch(d){return d}})()},H0=(n,e,t)=>(r,i,s,l=!1)=>{const c=(u,d=void 0,h=void 0)=>Al(n.configurationName,t,n.publishEvent.bind(n))(u,d,h);return new Promise((u,d)=>{if(t.silent_login_uri&&t.silent_redirect_uri&&t.monitor_session&&r&&s&&!l){const h=()=>{n.checkSessionIFrame.stop();const p=n.tokens;if(p===null)return;const y=p.idToken,g=p.idTokenPayload;return c({prompt:"none",id_token_hint:y,scope:t.scope||"openid"}).then(_=>{if(_.error)throw new Error(_.error);const S=_.tokens.idTokenPayload;if(g.sub===S.sub){const k=_.sessionState;n.checkSessionIFrame.start(_.sessionState),g.sid===S.sid?console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",k):console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",k)}else console.debug("SessionMonitor._callback: Different subject signed into OP:",S.sub)}).catch(async _=>{console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:",_);for(const[,S]of Object.entries(e))await S.logoutOtherTabAsync(t.client_id,g.sub)})};n.checkSessionIFrame=new h0(h,i,r),n.checkSessionIFrame.load().then(()=>{n.checkSessionIFrame.start(s),u(n.checkSessionIFrame)}).catch(p=>{d(p)})}else u(null)})},U0=n=>!!(n.os==="iOS"&&n.osVersion.startsWith("12")||n.os==="Mac OS X"&&n.osVersion.startsWith("10_15_6")),K0=n=>{const e=n.appVersion,t=n.userAgent,r="-";let i=r;const s=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(const c in s){const u=s[c];if(u.r.test(t)){i=u.s;break}}let l=r;switch(/Windows/.test(i)&&(l=/Windows (.*)/.exec(i)[1],i="Windows"),i){case"Mac OS":case"Mac OS X":case"Android":l=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t)[1];break;case"iOS":{const c=/OS (\d+)_(\d+)_?(\d+)?/.exec(e);c!=null&&c.length>2&&(l=c[1]+"."+c[2]+"."+(parseInt(c[3])|0));break}}return{os:i,osVersion:l}};function j0(){const n=navigator.userAgent;let e,t=n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(t[1]))return e=/\brv[ :]+(\d+)/g.exec(n)||[],{name:"ie",version:e[1]||""};if(t[1]==="Chrome"&&(e=n.match(/\bOPR|Edge\/(\d+)/),e!=null)){let r=e[1];if(!r){const i=n.split(e[0]+"/");i.length>1&&(r=i[1])}return{name:"opera",version:r}}return t=t[2]?[t[1],t[2]]:[navigator.appName,navigator.appVersion,"-?"],(e=n.match(/version\/(\d+)/i))!=null&&t.splice(1,1,e[1]),{name:t[0].toLowerCase(),version:t[1]}}const q0=()=>{const{name:n,version:e}=j0();if(n==="chrome"&&parseInt(e)<=70||n==="opera"&&(!e||parseInt(e.split(".")[0])<80)||n==="ie")return!1;const t=K0(navigator);return!U0(t)},J0=async n=>{let e;if(n.tokens!=null)return!1;n.publishEvent(ae.tryKeepExistingSessionAsync_begin,{});try{const t=n.configuration,r=await n.initAsync(t.authority,t.authority_configuration);if(e=await It(t,n.configurationName),e){const{tokens:i}=await e.initAsync(r,"tryKeepExistingSessionAsync",t);if(i){e.startKeepAliveServiceWorker(),n.tokens=i;const s=e.getLoginParams(n.configurationName);n.timeoutId=Si(n,n.tokens.expiresAt,s.extras,s.scope);const l=await e.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,l),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside ServiceWorker are valid"}),!0}n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!1,message:"no exiting session found"})}else{t.service_worker_relative_url&&n.publishEvent(ae.service_worker_not_supported_by_browser,{message:"service worker is not supported by this browser"});const i=Nt(n.configurationName,t.storage??sessionStorage),{tokens:s}=await i.initAsync();if(s){n.tokens=Sl(s,null,t.token_renew_mode);const l=i.getLoginParams();n.timeoutId=Si(n,n.tokens.expiresAt,l.extras,l.scope);const c=await i.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,c),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside storage are valid"}),!0}}return n.publishEvent(ae.tryKeepExistingSessionAsync_end,{success:!1,message:e?"service worker sessions not retrieved":"session storage sessions not retrieved"}),!1}catch(t){return console.error(t),e&&await e.clearAsync(),n.publishEvent(ae.tryKeepExistingSessionAsync_error,"tokens inside ServiceWorker are invalid"),!1}},vf=n=>{const e=n.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);if(!e)throw new Error("Invalid URL");let t=e[6],r=e[7];if(r){const i=r.split("?");i.length===2&&(r=i[0],t=i[1])}return t.startsWith("?")&&(t=t.slice(1)),e&&{href:n,protocol:e[1],host:e[2],hostname:e[3],port:e[4],path:e[5],search:t,hash:r}},ki=n=>{const e=vf(n);let{path:t}=e;t.endsWith("/")&&(t=t.slice(0,-1));let{hash:r}=e;return r==="#_=_"&&(r=""),r&&(t+=r),t},ws=n=>{const e=vf(n),{search:t}=e;return G0(t)},G0=n=>{const e={};let t,r,i;const s=n.split("&");for(r=0,i=s.length;r<i;r++)t=s[r].split("="),e[decodeURIComponent(t[0])]=decodeURIComponent(t[1]);return e},Y0=(n,e,t,r,i)=>(s=void 0,l=null,c=!1,u=void 0)=>{const d=l;return l={...l},(async()=>{const h=s||i.getPath();if("state"in l||(l.state=Tl(16)),t(ae.loginAsync_begin,{}),l)for(const p of Object.keys(l))p.endsWith(":token_request")&&delete l[p];try{const p=c?e.silent_redirect_uri:e.redirect_uri;u||(u=e.scope);const y=e.extras?{...e.extras,...l}:l;y.nonce||(y.nonce=Tl(12));const g={nonce:y.nonce},_=await It(e,n),S=await r(e.authority,e.authority_configuration);let k;if(_)_.setLoginParams({callbackPath:h,extras:d,scope:u}),await _.initAsync(S,"loginAsync",e),await _.setNonceAsync(g),_.startKeepAliveServiceWorker(),k=_;else{const P=Nt(n,e.storage??sessionStorage);P.setLoginParams({callbackPath:h,extras:d,scope:u}),await P.setNonceAsync(g),k=P}const A={client_id:e.client_id,redirect_uri:p,scope:u,response_type:"code",...y};await z0(k,i)(S.authorizationEndpoint,A)}catch(p){throw t(ae.loginAsync_error,p),p}})()},Q0=n=>async(e=!1)=>{try{n.publishEvent(ae.loginCallbackAsync_begin,{});const t=n.configuration,r=t.client_id,i=e?t.silent_redirect_uri:t.redirect_uri,s=t.authority,l=t.token_request_timeout,c=await n.initAsync(s,t.authority_configuration),u=n.location.getCurrentHref(),d=ws(u),h=d.session_state,p=await It(t,n.configurationName);let y,g,_,S;if(p)await p.initAsync(c,"loginCallbackAsync",t),await p.setSessionStateAsync(h),g=await p.getNonceAsync(),_=p.getLoginParams(),S=await p.getStateAsync(),p.startKeepAliveServiceWorker(),y=p;else{const ne=Nt(n.configurationName,t.storage??sessionStorage);await ne.setSessionStateAsync(h),g=await ne.getNonceAsync(),_=ne.getLoginParams(),S=await ne.getStateAsync(),y=ne}if(d.error||d.error_description)throw new Error(`Error from OIDC server: ${d.error} - ${d.error_description}`);if(d.iss&&d.iss!==c.issuer)throw console.error(),new Error(`Issuer not valid (expected: ${c.issuer}, received: ${d.iss})`);if(d.state&&d.state!==S)throw new Error(`State not valid (expected: ${S}, received: ${d.state})`);const k={code:d.code,grant_type:"authorization_code",client_id:t.client_id,redirect_uri:i},A={};if(t.token_request_extras)for(const[ne,ve]of Object.entries(t.token_request_extras))A[ne]=ve;if(_!=null&&_.extras)for(const[ne,ve]of Object.entries(_.extras))ne.endsWith(":token_request")&&(A[ne.replace(":token_request","")]=ve);const P=c.tokenEndpoint,L={};if(t.demonstrating_proof_of_possession)if(p)L.DPoP=`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${n.configurationName}`;else{const ne=await N0(window)(t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);await Nt(n.configurationName,t.storage).setDemonstratingProofOfPossessionJwkAsync(ne),L.DPoP=await pf(window)(t.demonstrating_proof_of_possession_configuration)(ne,"POST",P)}const B=await W0(y)(P,{...k,...A},L,n.configuration.token_renew_mode,l);if(!B.success)throw new Error("Token request failed");let W;const z=B.data.tokens,J=B.data.demonstratingProofOfPossessionNonce;if(B.data.state!==A.state)throw new Error("state is not valid");const{isValid:j,reason:V}=sf(z,g.nonce,c);if(!j)throw new Error(`Tokens are not OpenID valid, reason: ${V}`);if(p){if(z.refreshToken&&!z.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Refresh token should be hidden by service worker");if(J&&z!=null&&z.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Demonstration of proof of possession require Access token not hidden by service worker")}if(p)await p.initAsync(c,"syncTokensAsync",t),W=p.getLoginParams(),J&&await p.setDemonstratingProofOfPossessionNonce(J);else{const ne=Nt(n.configurationName,t.storage);W=ne.getLoginParams(),J&&await ne.setDemonstratingProofOfPossessionNonce(J)}return await n.startCheckSessionAsync(c.checkSessionIframe,r,h,e),n.publishEvent(ae.loginCallbackAsync_end,{}),{tokens:z,state:"request.state",callbackPath:W.callbackPath,scope:d.scope,extras:W.extras}}catch(t){throw console.error(t),n.publishEvent(ae.loginCallbackAsync_error,t),t}},wf={access_token:"access_token",refresh_token:"refresh_token"},Cl=(n,e)=>{const t={};if(n){for(const[r,i]of Object.entries(n))if(r.endsWith(e)){const s=r.replace(e,"");t[s]=i}return t}return t},X0=n=>{const e={};if(n){for(const[t,r]of Object.entries(n))t.includes(":")||(e[t]=r);return e}return e},Z0=n=>async e=>{Br.clearTimeout(n.timeoutId),n.timeoutId=null,n.checkSessionIFrame&&n.checkSessionIFrame.stop();const t=await It(n.configuration,n.configurationName);t?await t.clearAsync(e):await Nt(n.configurationName,n.configuration.storage).clearAsync(e),n.tokens=null,n.userInfo=null},e_=(n,e,t,r,i)=>async(s=void 0,l=null)=>{var c,u;const d=n.configuration,h=await n.initAsync(d.authority,d.authority_configuration);s&&typeof s!="string"&&(s=void 0,r.warn("callbackPathOrUrl path is not a string"));const p=s??i.getPath();let y=!1;s&&(y=s.includes("https://")||s.includes("http://"));const g=y?s:i.getOrigin()+p,_=n.tokens?n.tokens.idToken:"";try{const P=h.revocationEndpoint;if(P){const L=[],B=n.tokens?n.tokens.accessToken:null;if(B&&d.logout_tokens_to_invalidate.includes(wf.access_token)){const z=Cl(l,":revoke_access_token"),J=yf(t)(P,B,Ol.access_token,d.client_id,z);L.push(J)}const W=n.tokens?n.tokens.refreshToken:null;if(W&&d.logout_tokens_to_invalidate.includes(wf.refresh_token)){const z=Cl(l,":revoke_refresh_token"),J=yf(t)(P,W,Ol.refresh_token,d.client_id,z);L.push(J)}L.length>0&&await Promise.all(L)}}catch(P){r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"),r.warn(P)}const S=((u=(c=n.tokens)==null?void 0:c.idTokenPayload)==null?void 0:u.sub)??null;await n.destroyAsync("LOGGED_OUT");for(const[,P]of Object.entries(e))P!==n?await n.logoutSameTabAsync(n.configuration.client_id,S):n.publishEvent(ae.logout_from_same_tab,{});const k=Cl(l,":oidc");if(k&&k.no_reload==="true")return;const A=X0(l);if(h.endSessionEndpoint){"id_token_hint"in A||(A.id_token_hint=_),!("post_logout_redirect_uri"in A)&&s!==null&&(A.post_logout_redirect_uri=g);let P="";for(const[L,B]of Object.entries(A))B!=null&&(P===""?P+="?":P+="&",P+=`${L}=${encodeURIComponent(B)}`);i.open(`${h.endSessionEndpoint}${P}`)}else i.reload()},Sf=(n,e,t=!1)=>async(...r)=>{var i;const[s,l,...c]=r,u=l?{...l}:{method:"GET"};let d=new Headers;u.headers&&(d=u.headers instanceof Headers?u.headers:new Headers(u.headers));const h={getTokens:()=>e.tokens,configuration:{token_automatic_renew_mode:e.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:e.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:e.renewTokensAsync.bind(e)},p=await rf(h),y=(i=p==null?void 0:p.tokens)==null?void 0:i.accessToken;if(d.has("Accept")||d.set("Accept","application/json"),y){if(e.configuration.demonstrating_proof_of_possession&&t){const _=await e.generateDemonstrationOfProofOfPossessionAsync(y,s.toString(),u.method);d.set("Authorization",`DPoP ${y}`),d.set("DPoP",_)}else d.set("Authorization",`Bearer ${y}`);u.credentials||(u.credentials="same-origin")}const g={...u,headers:d};return await n(s,g,...c)},t_=n=>async(e=!1,t=!1)=>{if(n.userInfo!=null&&!e)return n.userInfo;const r=n.configuration,i=(await n.initAsync(r.authority,r.authority_configuration)).userInfoEndpoint,s=await(async()=>{const l=await Sf(fetch,n,t)(i);return l.status!==200?null:l.json()})();return n.userInfo=s,s},kf=()=>fetch;let Ml=class{constructor(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.checkSessionIframe=e.check_session_iframe,this.issuer=e.issuer,this.endSessionEndpoint=e.end_session_endpoint}};const ar={},n_=(n,e=new Dr)=>(t,r="default")=>(ar[r]||(ar[r]=new mn(t,r,n,e)),ar[r]),r_=async n=>{const{parsedTokens:e,callbackPath:t,extras:r,scope:i}=await n.loginCallbackAsync();return n.timeoutId=Si(n,e.expiresAt,r,i),{callbackPath:t}},i_=n=>Math.floor(Math.random()*n),Nl=class hy{constructor(e,t="default",r,i=new Dr){this.initPromise=null,this.tryKeepExistingSessionPromise=null,this.loginPromise=null,this.loginCallbackPromise=null,this.loginCallbackWithAutoTokensRenewPromise=null,this.userInfoPromise=null,this.renewTokensPromise=null,this.logoutPromise=null;let s=e.silent_login_uri;e.silent_redirect_uri&&!e.silent_login_uri&&(s=`${e.silent_redirect_uri.replace("-callback","").replace("callback","")}-login`);let l=e.refresh_time_before_tokens_expiration_in_second??120;l>60&&(l=l-Math.floor(Math.random()*40)),this.location=i??new Dr;const c=e.service_worker_update_require_callback??b0(this.location);this.configuration={...e,silent_login_uri:s,token_automatic_renew_mode:e.token_automatic_renew_mode??bi.AutomaticBeforeTokenExpiration,monitor_session:e.monitor_session??!1,refresh_time_before_tokens_expiration_in_second:l,silent_login_timeout:e.silent_login_timeout??12e3,token_renew_mode:e.token_renew_mode??wl.access_token_or_id_token_invalid,demonstrating_proof_of_possession:e.demonstrating_proof_of_possession??!1,authority_timeout_wellknowurl_in_millisecond:e.authority_timeout_wellknowurl_in_millisecond??1e4,logout_tokens_to_invalidate:e.logout_tokens_to_invalidate??["access_token","refresh_token"],service_worker_update_require_callback:c,service_worker_activate:e.service_worker_activate??q0,demonstrating_proof_of_possession_configuration:e.demonstrating_proof_of_possession_configuration??k0,preload_user_info:e.preload_user_info??!1},this.getFetch=r??kf,this.configurationName=t,this.tokens=null,this.userInfo=null,this.events=[],this.timeoutId=null,this.loginCallbackWithAutoTokensRenewAsync.bind(this),this.initAsync.bind(this),this.loginCallbackAsync.bind(this),this.subscribeEvents.bind(this),this.removeEventSubscription.bind(this),this.publishEvent.bind(this),this.destroyAsync.bind(this),this.logoutAsync.bind(this),this.renewTokensAsync.bind(this),this.initAsync(this.configuration.authority,this.configuration.authority_configuration)}subscribeEvents(e){const t=i_(9999999999999).toString();return this.events.push({id:t,func:e}),t}removeEventSubscription(e){const t=this.events.filter(r=>r.id!==e);this.events=t}publishEvent(e,t){this.events.forEach(r=>{r.func(e,t)})}static get(e="default"){const t=typeof process>"u";if(!Object.prototype.hasOwnProperty.call(ar,e)&&t)throw Error(`OIDC library does seem initialized.
24
+ Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> component.`);return ar[e]}_silentLoginCallbackFromIFrame(){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const e=this.location,t=ws(e.getCurrentHref());window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({tokens:this.tokens,sessionState:t.session_state})}`,e.getOrigin())}}_silentLoginErrorCallbackFromIFrame(e=null){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const t=this.location,r=ws(t.getCurrentHref());r.error?window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({error:r.error})}`,t.getOrigin()):window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({error:e==null?"":e.toString()})}`,t.getOrigin())}}async silentLoginCallbackAsync(){try{await this.loginCallbackAsync(!0),this._silentLoginCallbackFromIFrame()}catch(e){console.error(e),this._silentLoginErrorCallbackFromIFrame(e)}}async initAsync(e,t){if(this.initPromise!==null)return this.initPromise;const r=async()=>{if(t!=null)return new Ml({authorization_endpoint:t.authorization_endpoint,end_session_endpoint:t.end_session_endpoint,revocation_endpoint:t.revocation_endpoint,token_endpoint:t.token_endpoint,userinfo_endpoint:t.userinfo_endpoint,check_session_iframe:t.check_session_iframe,issuer:t.issuer});const i=await It(this.configuration,this.configurationName)?window.sessionStorage:null;return await B0(this.getFetch())(e,this.configuration.authority_time_cache_wellknowurl_in_second??60*60,i,this.configuration.authority_timeout_wellknowurl_in_millisecond)};return this.initPromise=r(),this.initPromise.finally(()=>{this.initPromise=null})}async tryKeepExistingSessionAsync(){return this.tryKeepExistingSessionPromise!==null?this.tryKeepExistingSessionPromise:(this.tryKeepExistingSessionPromise=J0(this),this.tryKeepExistingSessionPromise.finally(()=>{this.tryKeepExistingSessionPromise=null}))}async startCheckSessionAsync(e,t,r,i=!1){await H0(this,ar,this.configuration)(e,t,r,i)}async loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this.logoutPromise&&await this.logoutPromise,this.loginPromise!==null?this.loginPromise:(s?this.loginPromise=V0(window,this.configurationName,this.configuration,this.publishEvent.bind(this),this)(t,i):this.loginPromise=Y0(this.configurationName,this.configuration,this.publishEvent.bind(this),this.initAsync.bind(this),this.location)(e,t,r,i),this.loginPromise.finally(()=>{this.loginPromise=null}))}async loginCallbackAsync(e=!1){if(this.loginCallbackPromise!==null)return this.loginCallbackPromise;const t=async()=>{const r=await Q0(this)(e),i=r.tokens;return this.tokens=i,await It(this.configuration,this.configurationName)||Nt(this.configurationName,this.configuration.storage).setTokens(i),this.publishEvent(hy.eventNames.token_acquired,i),this.configuration.preload_user_info&&await this.userInfoAsync(),{parsedTokens:i,state:r.state,callbackPath:r.callbackPath,scope:r.scope,extras:r.extras}};return this.loginCallbackPromise=t(),this.loginCallbackPromise.finally(()=>{this.loginCallbackPromise=null})}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){const s=this.configuration,l={ath:await gf(e),...i};if(await It(s,this.configurationName))return`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${uf(this.configurationName)}`;const c=Nt(this.configurationName,s.storage),u=await c.getDemonstratingProofOfPossessionJwkAsync(),d=c.getDemonstratingProofOfPossessionNonce();return d&&(l.nonce=d),await pf(window)(s.demonstrating_proof_of_possession_configuration)(u,r,t,l)}loginCallbackWithAutoTokensRenewAsync(){return this.loginCallbackWithAutoTokensRenewPromise!==null?this.loginCallbackWithAutoTokensRenewPromise:(this.loginCallbackWithAutoTokensRenewPromise=r_(this),this.loginCallbackWithAutoTokensRenewPromise.finally(()=>{this.loginCallbackWithAutoTokensRenewPromise=null}))}userInfoAsync(e=!1,t=!1){return this.userInfoPromise!==null?this.userInfoPromise:(this.userInfoPromise=t_(this)(e,t),this.userInfoPromise.finally(()=>{this.userInfoPromise=null}))}async renewTokensAsync(e=null,t=null){if(this.renewTokensPromise!==null)return this.renewTokensPromise;if(this.timeoutId)return Br.clearTimeout(this.timeoutId),this.renewTokensPromise=bf(this,!0,e,t),this.renewTokensPromise.finally(()=>{this.renewTokensPromise=null})}async destroyAsync(e){return await Z0(this)(e)}async logoutSameTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ae.logout_from_same_tab,{mmessage:"SessionMonitor",sub:t}))}async logoutOtherTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ae.logout_from_another_tab,{message:"SessionMonitor",sub:t}))}async logoutAsync(e=void 0,t=null){return this.logoutPromise?this.logoutPromise:(this.logoutPromise=e_(this,ar,this.getFetch(),console,this.location)(e,t),this.logoutPromise.finally(()=>{this.logoutPromise=null}))}};Nl.getOrCreate=(n,e)=>(t,r="default")=>n_(n,e)(t,r),Nl.eventNames=ae;let mn=Nl;const Ss=class py{constructor(e){this._oidc=e}subscribeEvents(e){return this._oidc.subscribeEvents(e)}removeEventSubscription(e){this._oidc.removeEventSubscription(e)}publishEvent(e,t){this._oidc.publishEvent(e,t)}static get(e="default"){return new py(mn.get(e))}tryKeepExistingSessionAsync(){return this._oidc.tryKeepExistingSessionAsync()}loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this._oidc.loginAsync(e,t,r,i,s)}logoutAsync(e=void 0,t=null){return this._oidc.logoutAsync(e,t)}silentLoginCallbackAsync(){return this._oidc.silentLoginCallbackAsync()}renewTokensAsync(e=null,t=null){return this._oidc.renewTokensAsync(e,t)}loginCallbackAsync(){return this._oidc.loginCallbackWithAutoTokensRenewAsync()}get tokens(){return this._oidc.tokens}get configuration(){return this._oidc.configuration}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e,t,r,i)}async getValidTokenAsync(e=200,t=50){const r=this._oidc,i={getTokens:()=>r.tokens,configuration:{token_automatic_renew_mode:r.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:r.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:r.renewTokensAsync.bind(r)};return rf(i,e,t)}fetchWithTokens(e,t=!1){return Sf(e,this._oidc,t)}async userInfoAsync(e=!1,t=!1){return this._oidc.userInfoAsync(e,t)}userInfo(){return this._oidc.userInfo}};Ss.getOrCreate=(n,e=new Dr)=>(t,r="default")=>new Ss(mn.getOrCreate(n,e)(t,r)),Ss.eventNames=mn.eventNames;let me=Ss;const xf=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),s_=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),o_=()=>Math.random().toString(36).slice(2,8),l_=(n,e)=>(t,r)=>{if(typeof n.CustomEvent=="function")return new n.CustomEvent(t,r);const i=r||{bubbles:!1,cancelable:!1,detail:void 0},s=e.createEvent("CustomEvent");return s.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),s.prototype=n.Event.prototype,s},a_=(n,e,t)=>({replaceState:(r,i)=>{const s=t(),l=i||n.history.state;n.history.replaceState({key:s,state:l},null,r),n.dispatchEvent(e("popstate"))}}),c_=()=>a_(window,l_(window,document),o_),Ef=()=>Y.jsx("div",{className:"oidc-callback",children:Y.jsxs("div",{className:"oidc-callback__container",children:[Y.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),Y.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),u_=({callBackError:n,callBackSuccess:e,configurationName:t,withCustomHistory:r})=>{const[i,s]=K.useState(!1);K.useEffect(()=>{let u=!0;return(async()=>{const d=me.get;try{const{callbackPath:h}=await d(t).loginCallbackAsync();(r?r():c_()).replaceState(h||"/")}catch(h){u&&(console.warn(h),s(!0))}})(),()=>{u=!1}},[]);const l=n||xf,c=e||Ef;return i?Y.jsx(l,{configurationName:t}):Y.jsx(c,{configurationName:t})},f_=()=>Y.jsx("span",{className:"oidc-loading",children:"Loading"}),d_=()=>Y.jsx("div",{className:"oidc-serviceworker",children:Y.jsxs("div",{className:"oidc-serviceworker__container",children:[Y.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),Y.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),h_=()=>Y.jsx("div",{className:"oidc-session-lost",children:Y.jsxs("div",{className:"oidc-session-lost__container",children:[Y.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),Y.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),p_=({configurationName:n})=>(K.useEffect(()=>{(async()=>{me.get(n).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[n]),null),m_=({configurationName:n})=>{const e=ws(window.location.href),t=me.get,r=t(n);let i=null;for(const[s,l]of Object.entries(e))s==="state"||s==="scope"||(i===null&&(i={}),i[s]=l);return K.useEffect(()=>{r.tokens||r.loginAsync(null,i,!0,e.scope)},[]),Y.jsx(Y.Fragment,{})},g_=({callbackErrorComponent:n,callbackSuccessComponent:e,redirect_uri:t,silent_redirect_uri:r,silent_login_uri:i,children:s,configurationName:l,withCustomHistory:c=null})=>{const u=window?ki(window.location.href):"",[d,h]=K.useState(u);K.useEffect(()=>{const y=()=>h(ki(window.location.href));return y(),window.addEventListener("popstate",y,!1),()=>window.removeEventListener("popstate",y,!1)},[]);const p=ki(t);if(r&&d===ki(r))return Y.jsx(p_,{configurationName:l});if(i&&d===ki(i))return Y.jsx(m_,{configurationName:l});switch(d){case p:return Y.jsx(u_,{callBackError:n,callBackSuccess:e,configurationName:l,withCustomHistory:c});default:return Y.jsx(Y.Fragment,{children:s})}},y_=K.memo(g_),Tf={name:"",data:null},__=({loadingComponent:n,children:e,configurationName:t})=>{const[r,i]=K.useState(!0),s=me.get,l=s(t);return K.useEffect(()=>{let c=!0;return l&&l.tryKeepExistingSessionAsync().then(()=>{c&&i(!1)}),()=>{c=!1}},[t]),Y.jsx(Y.Fragment,{children:r?Y.jsx(n,{configurationName:t}):Y.jsx(Y.Fragment,{children:e})})},xi=({isLoading:n,loadingComponent:e,children:t,configurationName:r})=>{const i=e;return n?Y.jsx(i,{configurationName:r,children:t}):Y.jsx(Y.Fragment,{children:t})},b_=({children:n,configuration:e,configurationName:t="default",callbackSuccessComponent:r=Ef,authenticatingComponent:i=s_,loadingComponent:s=f_,serviceWorkerNotSupportedComponent:l=d_,authenticatingErrorComponent:c=xf,sessionLostComponent:u=h_,onSessionLost:d=null,onLogoutFromAnotherTab:h=null,onLogoutFromSameTab:p=null,withCustomHistory:y=null,onEvent:g=null,getFetch:_=null,location:S=null})=>{const k=(Ke="default")=>me.getOrCreate(_??kf,S??new Dr)(e,Ke),[A,P]=K.useState(!0),[L,B]=K.useState(Tf),[W,z]=K.useState("default");K.useEffect(()=>{const Ke=k(t).subscribeEvents((Me,ft)=>{g&&g(t,Me,ft)});return()=>{k(t).removeEventSubscription(Ke)}},[t,g]),K.useEffect(()=>{const Ke=k(t).subscribeEvents((Me,ft)=>{if(Me===me.eventNames.refreshTokensAsync_error||Me===me.eventNames.syncTokensAsync_error){if(d!=null){d();return}B({name:Me,data:ft})}else if(Me===me.eventNames.logout_from_another_tab){if(h!=null){h();return}B({name:Me,data:ft})}else Me===me.eventNames.logout_from_same_tab?p!=null&&p():Me===me.eventNames.loginAsync_begin||Me===me.eventNames.loginCallbackAsync_end||Me===me.eventNames.loginAsync_error||Me===me.eventNames.loginCallbackAsync_error?B({name:Me,data:ft}):Me===me.eventNames.service_worker_not_supported_by_browser&&e.service_worker_only===!0&&B({name:Me,data:ft})});return z(t),P(!1),()=>{k(t).removeEventSubscription(Ke),B(Tf)}},[e,t]);const J=u,j=i,V=s,ne=l,ve=c,Le=A||W!==t,_t=k(t);switch(L.name){case me.eventNames.service_worker_not_supported_by_browser:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(ne,{configurationName:t})});case me.eventNames.loginAsync_begin:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(j,{configurationName:t})});case me.eventNames.loginAsync_error:case me.eventNames.loginCallbackAsync_error:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(ve,{configurationName:t})});case me.eventNames.refreshTokensAsync_error:case me.eventNames.syncTokensAsync_error:case me.eventNames.logout_from_another_tab:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(J,{configurationName:t})});default:return Y.jsx(xi,{loadingComponent:V,isLoading:Le,configurationName:t,children:Y.jsx(y_,{redirect_uri:_t.configuration.redirect_uri,silent_redirect_uri:_t.configuration.silent_redirect_uri,silent_login_uri:_t.configuration.silent_login_uri,callbackSuccessComponent:r,callbackErrorComponent:c,authenticatingComponent:i,configurationName:t,withCustomHistory:y,location:S??new Dr,children:Y.jsx(__,{loadingComponent:V,configurationName:t,children:n})})})}},Of="default",Il=(n,e)=>{let t=!1;return n(e)&&(t=n(e).tokens!=null),t},v_=(n=Of)=>{const e=me.get,[t,r]=K.useState(Il(e,n));return K.useEffect(()=>{let i=!0;const s=e(n);r(Il(e,n));const l=s.subscribeEvents((c,u)=>{(c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.token_acquired)&&i&&r(Il(e,n))});return()=>{i=!1,s.removeEventSubscription(l)}},[n]),{login:(i=void 0,s=void 0,l=!1,c=void 0)=>e(n).loginAsync(i,s,!1,c,l),logout:(i=void 0,s=void 0)=>e(n).logoutAsync(i,s),renewTokens:async(i=void 0)=>{const s=await e(n).renewTokensAsync(i);return{accessToken:s.accessToken,accessTokenPayload:s.accessTokenPayload,idToken:s.idToken,idTokenPayload:s.idTokenPayload}},isAuthenticated:t}},Af={accessToken:null,accessTokenPayload:null},w_=n=>{const e=me.get,t=e(n);if(t.tokens){const r=t.tokens;return{accessToken:r.accessToken,accessTokenPayload:r.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:t.configuration.demonstrating_proof_of_possession?(i,s)=>t.generateDemonstrationOfProofOfPossessionAsync(r.accessToken,i,s):null}}return Af};function S_(n,e){return n.configuration.demonstrating_proof_of_possession?(t,r,i={})=>n.generateDemonstrationOfProofOfPossessionAsync(e.accessToken,t,r,i):null}const k_=(n=Of)=>{const e=me.get,[t,r]=K.useState(w_(n));return K.useEffect(()=>{let i=!0;const s=e(n);if(s.tokens){const c=s.tokens;r({accessToken:c.accessToken,accessTokenPayload:c.accessTokenPayload})}const l=s.subscribeEvents((c,u)=>{if((c===me.eventNames.token_renewed||c===me.eventNames.token_acquired||c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.refreshTokensAsync_error||c===me.eventNames.syncTokensAsync_error)&&i){const d=s.tokens;r(d!=null?{accessToken:d.accessToken,accessTokenPayload:d.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:S_(s,d)}:Af)}});return()=>{i=!1,s.removeEventSubscription(l)}},[n]),t},x_=sr.graphql(`
25
25
  query players(
26
26
  $ids: [ID!]!
27
27
  $page: PageInfo!
@@ -39,6 +39,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
39
39
  value
40
40
  }
41
41
  identities {
42
+ providerId
42
43
  properties {
43
44
  property
44
45
  value
@@ -47,7 +48,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
47
48
  }
48
49
  }
49
50
  }
50
- `),Cf=({playerIds:n,skip:e})=>{const[t,r]=K.useState([]),[i,s]=K.useState(!e),[l]=Qu(x_),c=async u=>{var h,p;const d=[];for(;u.length>0;)d.push(...((p=(h=(await l({variables:{page:{first:100},ids:u.splice(0,100)}})).data)==null?void 0:h.players)==null?void 0:p.nodes)??[]);r(d)};return K.useEffect(()=>{!e&&n&&(s(!0),c(n).finally(()=>s(!1)))},[e,n]),{results:t,refetch:c,loading:i}},E_=Pr.graphql(`
51
+ `),Cf=({playerIds:n,skip:e})=>{const[t,r]=K.useState([]),[i,s]=K.useState(!e),[l]=Qu(x_),c=async u=>{var h,p;const d=[];for(;u.length>0;)d.push(...((p=(h=(await l({variables:{page:{first:100},ids:u.splice(0,100)}})).data)==null?void 0:h.players)==null?void 0:p.nodes)??[]);r(d)};return K.useEffect(()=>{!e&&n&&(s(!0),c(n).finally(()=>s(!1)))},[e,n]),{results:t,refetch:c,loading:i}},E_=sr.graphql(`
51
52
  query getMyAccount {
52
53
  getMyAccount {
53
54
  id
@@ -64,6 +65,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
64
65
  }
65
66
  }
66
67
  identities {
68
+ providerId
67
69
  properties {
68
70
  property
69
71
  value
@@ -71,7 +73,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
71
73
  }
72
74
  }
73
75
  }
74
- `),T_=()=>{const n=v_(),{data:e,loading:t,refetch:r}=ml(E_,{skip:!n.isAuthenticated,notifyOnNetworkStatusChange:!0});return{loading:t,data:e,refetch:r,authenticated:n.isAuthenticated,login:n.login,logout:n.logout}},O_=Pr.graphql(`
76
+ `),T_=()=>{const n=v_(),{data:e,loading:t,refetch:r}=ml(E_,{skip:!n.isAuthenticated,notifyOnNetworkStatusChange:!0});return{loading:t,data:e,refetch:r,authenticated:n.isAuthenticated,login:n.login,logout:n.logout}},O_=sr.graphql(`
75
77
  query tournamentTeam(
76
78
  $tournamentId: ID!
77
79
  $page: PageInfo!
@@ -105,9 +107,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
105
107
  * Released under MIT license <https://lodash.com/license>
106
108
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
107
109
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
108
- */ks.exports,function(n,e){(function(){var t,r="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,y=2,g=4,_=1,S=2,k=1,A=2,P=4,L=8,B=16,W=32,z=64,J=128,j=256,V=512,ne=30,ve="...",Le=800,_t=16,Ke=1,Me=2,ft=3,Gt=1/0,wn=9007199254740991,uo=17976931348623157e292,F=NaN,te=4294967295,Ee=te-1,je=te>>>1,cn=[["ary",J],["bind",k],["bindKey",A],["curry",L],["curryRight",B],["flip",V],["partial",W],["partialRight",z],["rearg",j]],Xe="[object Arguments]",Gn="[object Array]",Ui="[object AsyncFunction]",Ne="[object Boolean]",Ft="[object Date]",Ki="[object DOMException]",Zr="[object Error]",fo="[object Function]",Lp="[object GeneratorFunction]",Yt="[object Map]",ji="[object Number]",Yx="[object Null]",Sn="[object Object]",Bp="[object Promise]",Qx="[object Proxy]",qi="[object RegExp]",Qt="[object Set]",Ji="[object String]",ho="[object Symbol]",Xx="[object Undefined]",Gi="[object WeakMap]",Zx="[object WeakSet]",Yi="[object ArrayBuffer]",ei="[object DataView]",Ya="[object Float32Array]",Qa="[object Float64Array]",Xa="[object Int8Array]",Za="[object Int16Array]",ec="[object Int32Array]",tc="[object Uint8Array]",nc="[object Uint8ClampedArray]",rc="[object Uint16Array]",ic="[object Uint32Array]",e1=/\b__p \+= '';/g,t1=/\b(__p \+=) '' \+/g,n1=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fp=/&(?:amp|lt|gt|quot|#39);/g,zp=/[&<>"']/g,r1=RegExp(Fp.source),i1=RegExp(zp.source),s1=/<%-([\s\S]+?)%>/g,o1=/<%([\s\S]+?)%>/g,Wp=/<%=([\s\S]+?)%>/g,l1=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a1=/^\w*$/,c1=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,sc=/[\\^$.*+?()[\]{}|]/g,u1=RegExp(sc.source),oc=/^\s+/,f1=/\s/,d1=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,h1=/\{\n\/\* \[wrapped with (.+)\] \*/,p1=/,? & /,m1=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,g1=/[()=,{}\[\]\/\s]/,y1=/\\(\\)?/g,_1=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,$p=/\w*$/,b1=/^[-+]0x[0-9a-f]+$/i,v1=/^0b[01]+$/i,w1=/^\[object .+?Constructor\]$/,S1=/^0o[0-7]+$/i,k1=/^(?:0|[1-9]\d*)$/,x1=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,po=/($^)/,E1=/['\n\r\u2028\u2029\\]/g,mo="\\ud800-\\udfff",T1="\\u0300-\\u036f",O1="\\ufe20-\\ufe2f",A1="\\u20d0-\\u20ff",Vp=T1+O1+A1,Hp="\\u2700-\\u27bf",Up="a-z\\xdf-\\xf6\\xf8-\\xff",C1="\\xac\\xb1\\xd7\\xf7",M1="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",N1="\\u2000-\\u206f",I1=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Kp="A-Z\\xc0-\\xd6\\xd8-\\xde",jp="\\ufe0e\\ufe0f",qp=C1+M1+N1+I1,lc="['’]",P1="["+mo+"]",Jp="["+qp+"]",go="["+Vp+"]",Gp="\\d+",R1="["+Hp+"]",Yp="["+Up+"]",Qp="[^"+mo+qp+Gp+Hp+Up+Kp+"]",ac="\\ud83c[\\udffb-\\udfff]",D1="(?:"+go+"|"+ac+")",Xp="[^"+mo+"]",cc="(?:\\ud83c[\\udde6-\\uddff]){2}",uc="[\\ud800-\\udbff][\\udc00-\\udfff]",ti="["+Kp+"]",Zp="\\u200d",em="(?:"+Yp+"|"+Qp+")",L1="(?:"+ti+"|"+Qp+")",tm="(?:"+lc+"(?:d|ll|m|re|s|t|ve))?",nm="(?:"+lc+"(?:D|LL|M|RE|S|T|VE))?",rm=D1+"?",im="["+jp+"]?",B1="(?:"+Zp+"(?:"+[Xp,cc,uc].join("|")+")"+im+rm+")*",F1="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",z1="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",sm=im+rm+B1,W1="(?:"+[R1,cc,uc].join("|")+")"+sm,$1="(?:"+[Xp+go+"?",go,cc,uc,P1].join("|")+")",V1=RegExp(lc,"g"),H1=RegExp(go,"g"),fc=RegExp(ac+"(?="+ac+")|"+$1+sm,"g"),U1=RegExp([ti+"?"+Yp+"+"+tm+"(?="+[Jp,ti,"$"].join("|")+")",L1+"+"+nm+"(?="+[Jp,ti+em,"$"].join("|")+")",ti+"?"+em+"+"+tm,ti+"+"+nm,z1,F1,Gp,W1].join("|"),"g"),K1=RegExp("["+Zp+mo+Vp+jp+"]"),j1=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,q1=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],J1=-1,Te={};Te[Ya]=Te[Qa]=Te[Xa]=Te[Za]=Te[ec]=Te[tc]=Te[nc]=Te[rc]=Te[ic]=!0,Te[Xe]=Te[Gn]=Te[Yi]=Te[Ne]=Te[ei]=Te[Ft]=Te[Zr]=Te[fo]=Te[Yt]=Te[ji]=Te[Sn]=Te[qi]=Te[Qt]=Te[Ji]=Te[Gi]=!1;var ke={};ke[Xe]=ke[Gn]=ke[Yi]=ke[ei]=ke[Ne]=ke[Ft]=ke[Ya]=ke[Qa]=ke[Xa]=ke[Za]=ke[ec]=ke[Yt]=ke[ji]=ke[Sn]=ke[qi]=ke[Qt]=ke[Ji]=ke[ho]=ke[tc]=ke[nc]=ke[rc]=ke[ic]=!0,ke[Zr]=ke[fo]=ke[Gi]=!1;var G1={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Y1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Q1={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},X1={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Z1=parseFloat,eE=parseInt,om=typeof mi=="object"&&mi&&mi.Object===Object&&mi,tE=typeof self=="object"&&self&&self.Object===Object&&self,Ze=om||tE||Function("return this")(),dc=e&&!e.nodeType&&e,xr=dc&&!0&&n&&!n.nodeType&&n,lm=xr&&xr.exports===dc,hc=lm&&om.process,zt=function(){try{var T=xr&&xr.require&&xr.require("util").types;return T||hc&&hc.binding&&hc.binding("util")}catch{}}(),am=zt&&zt.isArrayBuffer,cm=zt&&zt.isDate,um=zt&&zt.isMap,fm=zt&&zt.isRegExp,dm=zt&&zt.isSet,hm=zt&&zt.isTypedArray;function Et(T,M,C){switch(C.length){case 0:return T.call(M);case 1:return T.call(M,C[0]);case 2:return T.call(M,C[0],C[1]);case 3:return T.call(M,C[0],C[1],C[2])}return T.apply(M,C)}function nE(T,M,C,U){for(var ie=-1,ye=T==null?0:T.length;++ie<ye;){var ze=T[ie];M(U,ze,C(ze),T)}return U}function Wt(T,M){for(var C=-1,U=T==null?0:T.length;++C<U&&M(T[C],C,T)!==!1;);return T}function rE(T,M){for(var C=T==null?0:T.length;C--&&M(T[C],C,T)!==!1;);return T}function pm(T,M){for(var C=-1,U=T==null?0:T.length;++C<U;)if(!M(T[C],C,T))return!1;return!0}function Yn(T,M){for(var C=-1,U=T==null?0:T.length,ie=0,ye=[];++C<U;){var ze=T[C];M(ze,C,T)&&(ye[ie++]=ze)}return ye}function yo(T,M){var C=T==null?0:T.length;return!!C&&ni(T,M,0)>-1}function pc(T,M,C){for(var U=-1,ie=T==null?0:T.length;++U<ie;)if(C(M,T[U]))return!0;return!1}function Oe(T,M){for(var C=-1,U=T==null?0:T.length,ie=Array(U);++C<U;)ie[C]=M(T[C],C,T);return ie}function Qn(T,M){for(var C=-1,U=M.length,ie=T.length;++C<U;)T[ie+C]=M[C];return T}function mc(T,M,C,U){var ie=-1,ye=T==null?0:T.length;for(U&&ye&&(C=T[++ie]);++ie<ye;)C=M(C,T[ie],ie,T);return C}function iE(T,M,C,U){var ie=T==null?0:T.length;for(U&&ie&&(C=T[--ie]);ie--;)C=M(C,T[ie],ie,T);return C}function gc(T,M){for(var C=-1,U=T==null?0:T.length;++C<U;)if(M(T[C],C,T))return!0;return!1}var sE=yc("length");function oE(T){return T.split("")}function lE(T){return T.match(m1)||[]}function mm(T,M,C){var U;return C(T,function(ie,ye,ze){if(M(ie,ye,ze))return U=ye,!1}),U}function _o(T,M,C,U){for(var ie=T.length,ye=C+(U?1:-1);U?ye--:++ye<ie;)if(M(T[ye],ye,T))return ye;return-1}function ni(T,M,C){return M===M?bE(T,M,C):_o(T,gm,C)}function aE(T,M,C,U){for(var ie=C-1,ye=T.length;++ie<ye;)if(U(T[ie],M))return ie;return-1}function gm(T){return T!==T}function ym(T,M){var C=T==null?0:T.length;return C?bc(T,M)/C:F}function yc(T){return function(M){return M==null?t:M[T]}}function _c(T){return function(M){return T==null?t:T[M]}}function _m(T,M,C,U,ie){return ie(T,function(ye,ze,Se){C=U?(U=!1,ye):M(C,ye,ze,Se)}),C}function cE(T,M){var C=T.length;for(T.sort(M);C--;)T[C]=T[C].value;return T}function bc(T,M){for(var C,U=-1,ie=T.length;++U<ie;){var ye=M(T[U]);ye!==t&&(C=C===t?ye:C+ye)}return C}function vc(T,M){for(var C=-1,U=Array(T);++C<T;)U[C]=M(C);return U}function uE(T,M){return Oe(M,function(C){return[C,T[C]]})}function bm(T){return T&&T.slice(0,km(T)+1).replace(oc,"")}function Tt(T){return function(M){return T(M)}}function wc(T,M){return Oe(M,function(C){return T[C]})}function Qi(T,M){return T.has(M)}function vm(T,M){for(var C=-1,U=T.length;++C<U&&ni(M,T[C],0)>-1;);return C}function wm(T,M){for(var C=T.length;C--&&ni(M,T[C],0)>-1;);return C}function fE(T,M){for(var C=T.length,U=0;C--;)T[C]===M&&++U;return U}var dE=_c(G1),hE=_c(Y1);function pE(T){return"\\"+X1[T]}function mE(T,M){return T==null?t:T[M]}function ri(T){return K1.test(T)}function gE(T){return j1.test(T)}function yE(T){for(var M,C=[];!(M=T.next()).done;)C.push(M.value);return C}function Sc(T){var M=-1,C=Array(T.size);return T.forEach(function(U,ie){C[++M]=[ie,U]}),C}function Sm(T,M){return function(C){return T(M(C))}}function Xn(T,M){for(var C=-1,U=T.length,ie=0,ye=[];++C<U;){var ze=T[C];(ze===M||ze===h)&&(T[C]=h,ye[ie++]=C)}return ye}function bo(T){var M=-1,C=Array(T.size);return T.forEach(function(U){C[++M]=U}),C}function _E(T){var M=-1,C=Array(T.size);return T.forEach(function(U){C[++M]=[U,U]}),C}function bE(T,M,C){for(var U=C-1,ie=T.length;++U<ie;)if(T[U]===M)return U;return-1}function vE(T,M,C){for(var U=C+1;U--;)if(T[U]===M)return U;return U}function ii(T){return ri(T)?SE(T):sE(T)}function Xt(T){return ri(T)?kE(T):oE(T)}function km(T){for(var M=T.length;M--&&f1.test(T.charAt(M)););return M}var wE=_c(Q1);function SE(T){for(var M=fc.lastIndex=0;fc.test(T);)++M;return M}function kE(T){return T.match(fc)||[]}function xE(T){return T.match(U1)||[]}var EE=function T(M){M=M==null?Ze:si.defaults(Ze.Object(),M,si.pick(Ze,q1));var C=M.Array,U=M.Date,ie=M.Error,ye=M.Function,ze=M.Math,Se=M.Object,kc=M.RegExp,TE=M.String,$t=M.TypeError,vo=C.prototype,OE=ye.prototype,oi=Se.prototype,wo=M["__core-js_shared__"],So=OE.toString,be=oi.hasOwnProperty,AE=0,xm=function(){var o=/[^.]+$/.exec(wo&&wo.keys&&wo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),ko=oi.toString,CE=So.call(Se),ME=Ze._,NE=kc("^"+So.call(be).replace(sc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xo=lm?M.Buffer:t,Zn=M.Symbol,Eo=M.Uint8Array,Em=xo?xo.allocUnsafe:t,To=Sm(Se.getPrototypeOf,Se),Tm=Se.create,Om=oi.propertyIsEnumerable,Oo=vo.splice,Am=Zn?Zn.isConcatSpreadable:t,Xi=Zn?Zn.iterator:t,Er=Zn?Zn.toStringTag:t,Ao=function(){try{var o=Mr(Se,"defineProperty");return o({},"",{}),o}catch{}}(),IE=M.clearTimeout!==Ze.clearTimeout&&M.clearTimeout,PE=U&&U.now!==Ze.Date.now&&U.now,RE=M.setTimeout!==Ze.setTimeout&&M.setTimeout,Co=ze.ceil,Mo=ze.floor,xc=Se.getOwnPropertySymbols,DE=xo?xo.isBuffer:t,Cm=M.isFinite,LE=vo.join,BE=Sm(Se.keys,Se),We=ze.max,st=ze.min,FE=U.now,zE=M.parseInt,Mm=ze.random,WE=vo.reverse,Ec=Mr(M,"DataView"),Zi=Mr(M,"Map"),Tc=Mr(M,"Promise"),li=Mr(M,"Set"),es=Mr(M,"WeakMap"),ts=Mr(Se,"create"),No=es&&new es,ai={},$E=Nr(Ec),VE=Nr(Zi),HE=Nr(Tc),UE=Nr(li),KE=Nr(es),Io=Zn?Zn.prototype:t,ns=Io?Io.valueOf:t,Nm=Io?Io.toString:t;function v(o){if(Ie(o)&&!se(o)&&!(o instanceof he)){if(o instanceof Vt)return o;if(be.call(o,"__wrapped__"))return Ig(o)}return new Vt(o)}var ci=function(){function o(){}return function(a){if(!Ae(a))return{};if(Tm)return Tm(a);o.prototype=a;var f=new o;return o.prototype=t,f}}();function Po(){}function Vt(o,a){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!a,this.__index__=0,this.__values__=t}v.templateSettings={escape:s1,evaluate:o1,interpolate:Wp,variable:"",imports:{_:v}},v.prototype=Po.prototype,v.prototype.constructor=v,Vt.prototype=ci(Po.prototype),Vt.prototype.constructor=Vt;function he(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=te,this.__views__=[]}function jE(){var o=new he(this.__wrapped__);return o.__actions__=bt(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=bt(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=bt(this.__views__),o}function qE(){if(this.__filtered__){var o=new he(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function JE(){var o=this.__wrapped__.value(),a=this.__dir__,f=se(o),m=a<0,b=f?o.length:0,w=oO(0,b,this.__views__),x=w.start,E=w.end,O=E-x,N=m?E:x-1,I=this.__iteratees__,R=I.length,$=0,G=st(O,this.__takeCount__);if(!f||!m&&b==O&&G==O)return tg(o,this.__actions__);var Z=[];e:for(;O--&&$<G;){N+=a;for(var ce=-1,ee=o[N];++ce<R;){var de=I[ce],pe=de.iteratee,Ct=de.type,pt=pe(ee);if(Ct==Me)ee=pt;else if(!pt){if(Ct==Ke)continue e;break e}}Z[$++]=ee}return Z}he.prototype=ci(Po.prototype),he.prototype.constructor=he;function Tr(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function GE(){this.__data__=ts?ts(null):{},this.size=0}function YE(o){var a=this.has(o)&&delete this.__data__[o];return this.size-=a?1:0,a}function QE(o){var a=this.__data__;if(ts){var f=a[o];return f===u?t:f}return be.call(a,o)?a[o]:t}function XE(o){var a=this.__data__;return ts?a[o]!==t:be.call(a,o)}function ZE(o,a){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=ts&&a===t?u:a,this}Tr.prototype.clear=GE,Tr.prototype.delete=YE,Tr.prototype.get=QE,Tr.prototype.has=XE,Tr.prototype.set=ZE;function kn(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function eT(){this.__data__=[],this.size=0}function tT(o){var a=this.__data__,f=Ro(a,o);if(f<0)return!1;var m=a.length-1;return f==m?a.pop():Oo.call(a,f,1),--this.size,!0}function nT(o){var a=this.__data__,f=Ro(a,o);return f<0?t:a[f][1]}function rT(o){return Ro(this.__data__,o)>-1}function iT(o,a){var f=this.__data__,m=Ro(f,o);return m<0?(++this.size,f.push([o,a])):f[m][1]=a,this}kn.prototype.clear=eT,kn.prototype.delete=tT,kn.prototype.get=nT,kn.prototype.has=rT,kn.prototype.set=iT;function xn(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function sT(){this.size=0,this.__data__={hash:new Tr,map:new(Zi||kn),string:new Tr}}function oT(o){var a=jo(this,o).delete(o);return this.size-=a?1:0,a}function lT(o){return jo(this,o).get(o)}function aT(o){return jo(this,o).has(o)}function cT(o,a){var f=jo(this,o),m=f.size;return f.set(o,a),this.size+=f.size==m?0:1,this}xn.prototype.clear=sT,xn.prototype.delete=oT,xn.prototype.get=lT,xn.prototype.has=aT,xn.prototype.set=cT;function Or(o){var a=-1,f=o==null?0:o.length;for(this.__data__=new xn;++a<f;)this.add(o[a])}function uT(o){return this.__data__.set(o,u),this}function fT(o){return this.__data__.has(o)}Or.prototype.add=Or.prototype.push=uT,Or.prototype.has=fT;function Zt(o){var a=this.__data__=new kn(o);this.size=a.size}function dT(){this.__data__=new kn,this.size=0}function hT(o){var a=this.__data__,f=a.delete(o);return this.size=a.size,f}function pT(o){return this.__data__.get(o)}function mT(o){return this.__data__.has(o)}function gT(o,a){var f=this.__data__;if(f instanceof kn){var m=f.__data__;if(!Zi||m.length<i-1)return m.push([o,a]),this.size=++f.size,this;f=this.__data__=new xn(m)}return f.set(o,a),this.size=f.size,this}Zt.prototype.clear=dT,Zt.prototype.delete=hT,Zt.prototype.get=pT,Zt.prototype.has=mT,Zt.prototype.set=gT;function Im(o,a){var f=se(o),m=!f&&Ir(o),b=!f&&!m&&ir(o),w=!f&&!m&&!b&&hi(o),x=f||m||b||w,E=x?vc(o.length,TE):[],O=E.length;for(var N in o)(a||be.call(o,N))&&!(x&&(N=="length"||b&&(N=="offset"||N=="parent")||w&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||An(N,O)))&&E.push(N);return E}function Pm(o){var a=o.length;return a?o[Bc(0,a-1)]:t}function yT(o,a){return qo(bt(o),Ar(a,0,o.length))}function _T(o){return qo(bt(o))}function Oc(o,a,f){(f!==t&&!en(o[a],f)||f===t&&!(a in o))&&En(o,a,f)}function rs(o,a,f){var m=o[a];(!(be.call(o,a)&&en(m,f))||f===t&&!(a in o))&&En(o,a,f)}function Ro(o,a){for(var f=o.length;f--;)if(en(o[f][0],a))return f;return-1}function bT(o,a,f,m){return er(o,function(b,w,x){a(m,b,f(b),x)}),m}function Rm(o,a){return o&&fn(a,qe(a),o)}function vT(o,a){return o&&fn(a,wt(a),o)}function En(o,a,f){a=="__proto__"&&Ao?Ao(o,a,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[a]=f}function Ac(o,a){for(var f=-1,m=a.length,b=C(m),w=o==null;++f<m;)b[f]=w?t:au(o,a[f]);return b}function Ar(o,a,f){return o===o&&(f!==t&&(o=o<=f?o:f),a!==t&&(o=o>=a?o:a)),o}function Ht(o,a,f,m,b,w){var x,E=a&p,O=a&y,N=a&g;if(f&&(x=b?f(o,m,b,w):f(o)),x!==t)return x;if(!Ae(o))return o;var I=se(o);if(I){if(x=aO(o),!E)return bt(o,x)}else{var R=ot(o),$=R==fo||R==Lp;if(ir(o))return ig(o,E);if(R==Sn||R==Xe||$&&!b){if(x=O||$?{}:kg(o),!E)return O?QT(o,vT(x,o)):YT(o,Rm(x,o))}else{if(!ke[R])return b?o:{};x=cO(o,R,E)}}w||(w=new Zt);var G=w.get(o);if(G)return G;w.set(o,x),Xg(o)?o.forEach(function(ee){x.add(Ht(ee,a,f,ee,o,w))}):Yg(o)&&o.forEach(function(ee,de){x.set(de,Ht(ee,a,f,de,o,w))});var Z=N?O?Jc:qc:O?wt:qe,ce=I?t:Z(o);return Wt(ce||o,function(ee,de){ce&&(de=ee,ee=o[de]),rs(x,de,Ht(ee,a,f,de,o,w))}),x}function wT(o){var a=qe(o);return function(f){return Dm(f,o,a)}}function Dm(o,a,f){var m=f.length;if(o==null)return!m;for(o=Se(o);m--;){var b=f[m],w=a[b],x=o[b];if(x===t&&!(b in o)||!w(x))return!1}return!0}function Lm(o,a,f){if(typeof o!="function")throw new $t(l);return fs(function(){o.apply(t,f)},a)}function is(o,a,f,m){var b=-1,w=yo,x=!0,E=o.length,O=[],N=a.length;if(!E)return O;f&&(a=Oe(a,Tt(f))),m?(w=pc,x=!1):a.length>=i&&(w=Qi,x=!1,a=new Or(a));e:for(;++b<E;){var I=o[b],R=f==null?I:f(I);if(I=m||I!==0?I:0,x&&R===R){for(var $=N;$--;)if(a[$]===R)continue e;O.push(I)}else w(a,R,m)||O.push(I)}return O}var er=cg(un),Bm=cg(Mc,!0);function ST(o,a){var f=!0;return er(o,function(m,b,w){return f=!!a(m,b,w),f}),f}function Do(o,a,f){for(var m=-1,b=o.length;++m<b;){var w=o[m],x=a(w);if(x!=null&&(E===t?x===x&&!At(x):f(x,E)))var E=x,O=w}return O}function kT(o,a,f,m){var b=o.length;for(f=le(f),f<0&&(f=-f>b?0:b+f),m=m===t||m>b?b:le(m),m<0&&(m+=b),m=f>m?0:ey(m);f<m;)o[f++]=a;return o}function Fm(o,a){var f=[];return er(o,function(m,b,w){a(m,b,w)&&f.push(m)}),f}function et(o,a,f,m,b){var w=-1,x=o.length;for(f||(f=fO),b||(b=[]);++w<x;){var E=o[w];a>0&&f(E)?a>1?et(E,a-1,f,m,b):Qn(b,E):m||(b[b.length]=E)}return b}var Cc=ug(),zm=ug(!0);function un(o,a){return o&&Cc(o,a,qe)}function Mc(o,a){return o&&zm(o,a,qe)}function Lo(o,a){return Yn(a,function(f){return Cn(o[f])})}function Cr(o,a){a=nr(a,o);for(var f=0,m=a.length;o!=null&&f<m;)o=o[dn(a[f++])];return f&&f==m?o:t}function Wm(o,a,f){var m=a(o);return se(o)?m:Qn(m,f(o))}function dt(o){return o==null?o===t?Xx:Yx:Er&&Er in Se(o)?sO(o):_O(o)}function Nc(o,a){return o>a}function xT(o,a){return o!=null&&be.call(o,a)}function ET(o,a){return o!=null&&a in Se(o)}function TT(o,a,f){return o>=st(a,f)&&o<We(a,f)}function Ic(o,a,f){for(var m=f?pc:yo,b=o[0].length,w=o.length,x=w,E=C(w),O=1/0,N=[];x--;){var I=o[x];x&&a&&(I=Oe(I,Tt(a))),O=st(I.length,O),E[x]=!f&&(a||b>=120&&I.length>=120)?new Or(x&&I):t}I=o[0];var R=-1,$=E[0];e:for(;++R<b&&N.length<O;){var G=I[R],Z=a?a(G):G;if(G=f||G!==0?G:0,!($?Qi($,Z):m(N,Z,f))){for(x=w;--x;){var ce=E[x];if(!(ce?Qi(ce,Z):m(o[x],Z,f)))continue e}$&&$.push(Z),N.push(G)}}return N}function OT(o,a,f,m){return un(o,function(b,w,x){a(m,f(b),w,x)}),m}function ss(o,a,f){a=nr(a,o),o=Og(o,a);var m=o==null?o:o[dn(Kt(a))];return m==null?t:Et(m,o,f)}function $m(o){return Ie(o)&&dt(o)==Xe}function AT(o){return Ie(o)&&dt(o)==Yi}function CT(o){return Ie(o)&&dt(o)==Ft}function ls(o,a,f,m,b){return o===a?!0:o==null||a==null||!Ie(o)&&!Ie(a)?o!==o&&a!==a:MT(o,a,f,m,ls,b)}function MT(o,a,f,m,b,w){var x=se(o),E=se(a),O=x?Gn:ot(o),N=E?Gn:ot(a);O=O==Xe?Sn:O,N=N==Xe?Sn:N;var I=O==Sn,R=N==Sn,$=O==N;if($&&ir(o)){if(!ir(a))return!1;x=!0,I=!1}if($&&!I)return w||(w=new Zt),x||hi(o)?vg(o,a,f,m,b,w):rO(o,a,O,f,m,b,w);if(!(f&_)){var G=I&&be.call(o,"__wrapped__"),Z=R&&be.call(a,"__wrapped__");if(G||Z){var ce=G?o.value():o,ee=Z?a.value():a;return w||(w=new Zt),b(ce,ee,f,m,w)}}return $?(w||(w=new Zt),iO(o,a,f,m,b,w)):!1}function NT(o){return Ie(o)&&ot(o)==Yt}function Pc(o,a,f,m){var b=f.length,w=b,x=!m;if(o==null)return!w;for(o=Se(o);b--;){var E=f[b];if(x&&E[2]?E[1]!==o[E[0]]:!(E[0]in o))return!1}for(;++b<w;){E=f[b];var O=E[0],N=o[O],I=E[1];if(x&&E[2]){if(N===t&&!(O in o))return!1}else{var R=new Zt;if(m)var $=m(N,I,O,o,a,R);if(!($===t?ls(I,N,_|S,m,R):$))return!1}}return!0}function Vm(o){if(!Ae(o)||hO(o))return!1;var a=Cn(o)?NE:w1;return a.test(Nr(o))}function IT(o){return Ie(o)&&dt(o)==qi}function PT(o){return Ie(o)&&ot(o)==Qt}function RT(o){return Ie(o)&&Zo(o.length)&&!!Te[dt(o)]}function Hm(o){return typeof o=="function"?o:o==null?St:typeof o=="object"?se(o)?jm(o[0],o[1]):Km(o):fy(o)}function Rc(o){if(!us(o))return BE(o);var a=[];for(var f in Se(o))be.call(o,f)&&f!="constructor"&&a.push(f);return a}function DT(o){if(!Ae(o))return yO(o);var a=us(o),f=[];for(var m in o)m=="constructor"&&(a||!be.call(o,m))||f.push(m);return f}function Dc(o,a){return o<a}function Um(o,a){var f=-1,m=vt(o)?C(o.length):[];return er(o,function(b,w,x){m[++f]=a(b,w,x)}),m}function Km(o){var a=Yc(o);return a.length==1&&a[0][2]?Eg(a[0][0],a[0][1]):function(f){return f===o||Pc(f,o,a)}}function jm(o,a){return Xc(o)&&xg(a)?Eg(dn(o),a):function(f){var m=au(f,o);return m===t&&m===a?cu(f,o):ls(a,m,_|S)}}function Bo(o,a,f,m,b){o!==a&&Cc(a,function(w,x){if(b||(b=new Zt),Ae(w))LT(o,a,x,f,Bo,m,b);else{var E=m?m(eu(o,x),w,x+"",o,a,b):t;E===t&&(E=w),Oc(o,x,E)}},wt)}function LT(o,a,f,m,b,w,x){var E=eu(o,f),O=eu(a,f),N=x.get(O);if(N){Oc(o,f,N);return}var I=w?w(E,O,f+"",o,a,x):t,R=I===t;if(R){var $=se(O),G=!$&&ir(O),Z=!$&&!G&&hi(O);I=O,$||G||Z?se(E)?I=E:Pe(E)?I=bt(E):G?(R=!1,I=ig(O,!0)):Z?(R=!1,I=sg(O,!0)):I=[]:ds(O)||Ir(O)?(I=E,Ir(E)?I=ty(E):(!Ae(E)||Cn(E))&&(I=kg(O))):R=!1}R&&(x.set(O,I),b(I,O,m,w,x),x.delete(O)),Oc(o,f,I)}function qm(o,a){var f=o.length;if(f)return a+=a<0?f:0,An(a,f)?o[a]:t}function Jm(o,a,f){a.length?a=Oe(a,function(w){return se(w)?function(x){return Cr(x,w.length===1?w[0]:w)}:w}):a=[St];var m=-1;a=Oe(a,Tt(X()));var b=Um(o,function(w,x,E){var O=Oe(a,function(N){return N(w)});return{criteria:O,index:++m,value:w}});return cE(b,function(w,x){return GT(w,x,f)})}function BT(o,a){return Gm(o,a,function(f,m){return cu(o,m)})}function Gm(o,a,f){for(var m=-1,b=a.length,w={};++m<b;){var x=a[m],E=Cr(o,x);f(E,x)&&as(w,nr(x,o),E)}return w}function FT(o){return function(a){return Cr(a,o)}}function Lc(o,a,f,m){var b=m?aE:ni,w=-1,x=a.length,E=o;for(o===a&&(a=bt(a)),f&&(E=Oe(o,Tt(f)));++w<x;)for(var O=0,N=a[w],I=f?f(N):N;(O=b(E,I,O,m))>-1;)E!==o&&Oo.call(E,O,1),Oo.call(o,O,1);return o}function Ym(o,a){for(var f=o?a.length:0,m=f-1;f--;){var b=a[f];if(f==m||b!==w){var w=b;An(b)?Oo.call(o,b,1):Wc(o,b)}}return o}function Bc(o,a){return o+Mo(Mm()*(a-o+1))}function zT(o,a,f,m){for(var b=-1,w=We(Co((a-o)/(f||1)),0),x=C(w);w--;)x[m?w:++b]=o,o+=f;return x}function Fc(o,a){var f="";if(!o||a<1||a>wn)return f;do a%2&&(f+=o),a=Mo(a/2),a&&(o+=o);while(a);return f}function fe(o,a){return tu(Tg(o,a,St),o+"")}function WT(o){return Pm(pi(o))}function $T(o,a){var f=pi(o);return qo(f,Ar(a,0,f.length))}function as(o,a,f,m){if(!Ae(o))return o;a=nr(a,o);for(var b=-1,w=a.length,x=w-1,E=o;E!=null&&++b<w;){var O=dn(a[b]),N=f;if(O==="__proto__"||O==="constructor"||O==="prototype")return o;if(b!=x){var I=E[O];N=m?m(I,O,E):t,N===t&&(N=Ae(I)?I:An(a[b+1])?[]:{})}rs(E,O,N),E=E[O]}return o}var Qm=No?function(o,a){return No.set(o,a),o}:St,VT=Ao?function(o,a){return Ao(o,"toString",{configurable:!0,enumerable:!1,value:fu(a),writable:!0})}:St;function HT(o){return qo(pi(o))}function Ut(o,a,f){var m=-1,b=o.length;a<0&&(a=-a>b?0:b+a),f=f>b?b:f,f<0&&(f+=b),b=a>f?0:f-a>>>0,a>>>=0;for(var w=C(b);++m<b;)w[m]=o[m+a];return w}function UT(o,a){var f;return er(o,function(m,b,w){return f=a(m,b,w),!f}),!!f}function Fo(o,a,f){var m=0,b=o==null?m:o.length;if(typeof a=="number"&&a===a&&b<=je){for(;m<b;){var w=m+b>>>1,x=o[w];x!==null&&!At(x)&&(f?x<=a:x<a)?m=w+1:b=w}return b}return zc(o,a,St,f)}function zc(o,a,f,m){var b=0,w=o==null?0:o.length;if(w===0)return 0;a=f(a);for(var x=a!==a,E=a===null,O=At(a),N=a===t;b<w;){var I=Mo((b+w)/2),R=f(o[I]),$=R!==t,G=R===null,Z=R===R,ce=At(R);if(x)var ee=m||Z;else N?ee=Z&&(m||$):E?ee=Z&&$&&(m||!G):O?ee=Z&&$&&!G&&(m||!ce):G||ce?ee=!1:ee=m?R<=a:R<a;ee?b=I+1:w=I}return st(w,Ee)}function Xm(o,a){for(var f=-1,m=o.length,b=0,w=[];++f<m;){var x=o[f],E=a?a(x):x;if(!f||!en(E,O)){var O=E;w[b++]=x===0?0:x}}return w}function Zm(o){return typeof o=="number"?o:At(o)?F:+o}function Ot(o){if(typeof o=="string")return o;if(se(o))return Oe(o,Ot)+"";if(At(o))return Nm?Nm.call(o):"";var a=o+"";return a=="0"&&1/o==-1/0?"-0":a}function tr(o,a,f){var m=-1,b=yo,w=o.length,x=!0,E=[],O=E;if(f)x=!1,b=pc;else if(w>=i){var N=a?null:tO(o);if(N)return bo(N);x=!1,b=Qi,O=new Or}else O=a?[]:E;e:for(;++m<w;){var I=o[m],R=a?a(I):I;if(I=f||I!==0?I:0,x&&R===R){for(var $=O.length;$--;)if(O[$]===R)continue e;a&&O.push(R),E.push(I)}else b(O,R,f)||(O!==E&&O.push(R),E.push(I))}return E}function Wc(o,a){return a=nr(a,o),o=Og(o,a),o==null||delete o[dn(Kt(a))]}function eg(o,a,f,m){return as(o,a,f(Cr(o,a)),m)}function zo(o,a,f,m){for(var b=o.length,w=m?b:-1;(m?w--:++w<b)&&a(o[w],w,o););return f?Ut(o,m?0:w,m?w+1:b):Ut(o,m?w+1:0,m?b:w)}function tg(o,a){var f=o;return f instanceof he&&(f=f.value()),mc(a,function(m,b){return b.func.apply(b.thisArg,Qn([m],b.args))},f)}function $c(o,a,f){var m=o.length;if(m<2)return m?tr(o[0]):[];for(var b=-1,w=C(m);++b<m;)for(var x=o[b],E=-1;++E<m;)E!=b&&(w[b]=is(w[b]||x,o[E],a,f));return tr(et(w,1),a,f)}function ng(o,a,f){for(var m=-1,b=o.length,w=a.length,x={};++m<b;){var E=m<w?a[m]:t;f(x,o[m],E)}return x}function Vc(o){return Pe(o)?o:[]}function Hc(o){return typeof o=="function"?o:St}function nr(o,a){return se(o)?o:Xc(o,a)?[o]:Ng(_e(o))}var KT=fe;function rr(o,a,f){var m=o.length;return f=f===t?m:f,!a&&f>=m?o:Ut(o,a,f)}var rg=IE||function(o){return Ze.clearTimeout(o)};function ig(o,a){if(a)return o.slice();var f=o.length,m=Em?Em(f):new o.constructor(f);return o.copy(m),m}function Uc(o){var a=new o.constructor(o.byteLength);return new Eo(a).set(new Eo(o)),a}function jT(o,a){var f=a?Uc(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.byteLength)}function qT(o){var a=new o.constructor(o.source,$p.exec(o));return a.lastIndex=o.lastIndex,a}function JT(o){return ns?Se(ns.call(o)):{}}function sg(o,a){var f=a?Uc(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.length)}function og(o,a){if(o!==a){var f=o!==t,m=o===null,b=o===o,w=At(o),x=a!==t,E=a===null,O=a===a,N=At(a);if(!E&&!N&&!w&&o>a||w&&x&&O&&!E&&!N||m&&x&&O||!f&&O||!b)return 1;if(!m&&!w&&!N&&o<a||N&&f&&b&&!m&&!w||E&&f&&b||!x&&b||!O)return-1}return 0}function GT(o,a,f){for(var m=-1,b=o.criteria,w=a.criteria,x=b.length,E=f.length;++m<x;){var O=og(b[m],w[m]);if(O){if(m>=E)return O;var N=f[m];return O*(N=="desc"?-1:1)}}return o.index-a.index}function lg(o,a,f,m){for(var b=-1,w=o.length,x=f.length,E=-1,O=a.length,N=We(w-x,0),I=C(O+N),R=!m;++E<O;)I[E]=a[E];for(;++b<x;)(R||b<w)&&(I[f[b]]=o[b]);for(;N--;)I[E++]=o[b++];return I}function ag(o,a,f,m){for(var b=-1,w=o.length,x=-1,E=f.length,O=-1,N=a.length,I=We(w-E,0),R=C(I+N),$=!m;++b<I;)R[b]=o[b];for(var G=b;++O<N;)R[G+O]=a[O];for(;++x<E;)($||b<w)&&(R[G+f[x]]=o[b++]);return R}function bt(o,a){var f=-1,m=o.length;for(a||(a=C(m));++f<m;)a[f]=o[f];return a}function fn(o,a,f,m){var b=!f;f||(f={});for(var w=-1,x=a.length;++w<x;){var E=a[w],O=m?m(f[E],o[E],E,f,o):t;O===t&&(O=o[E]),b?En(f,E,O):rs(f,E,O)}return f}function YT(o,a){return fn(o,Qc(o),a)}function QT(o,a){return fn(o,wg(o),a)}function Wo(o,a){return function(f,m){var b=se(f)?nE:bT,w=a?a():{};return b(f,o,X(m,2),w)}}function ui(o){return fe(function(a,f){var m=-1,b=f.length,w=b>1?f[b-1]:t,x=b>2?f[2]:t;for(w=o.length>3&&typeof w=="function"?(b--,w):t,x&&ht(f[0],f[1],x)&&(w=b<3?t:w,b=1),a=Se(a);++m<b;){var E=f[m];E&&o(a,E,m,w)}return a})}function cg(o,a){return function(f,m){if(f==null)return f;if(!vt(f))return o(f,m);for(var b=f.length,w=a?b:-1,x=Se(f);(a?w--:++w<b)&&m(x[w],w,x)!==!1;);return f}}function ug(o){return function(a,f,m){for(var b=-1,w=Se(a),x=m(a),E=x.length;E--;){var O=x[o?E:++b];if(f(w[O],O,w)===!1)break}return a}}function XT(o,a,f){var m=a&k,b=cs(o);function w(){var x=this&&this!==Ze&&this instanceof w?b:o;return x.apply(m?f:this,arguments)}return w}function fg(o){return function(a){a=_e(a);var f=ri(a)?Xt(a):t,m=f?f[0]:a.charAt(0),b=f?rr(f,1).join(""):a.slice(1);return m[o]()+b}}function fi(o){return function(a){return mc(cy(ay(a).replace(V1,"")),o,"")}}function cs(o){return function(){var a=arguments;switch(a.length){case 0:return new o;case 1:return new o(a[0]);case 2:return new o(a[0],a[1]);case 3:return new o(a[0],a[1],a[2]);case 4:return new o(a[0],a[1],a[2],a[3]);case 5:return new o(a[0],a[1],a[2],a[3],a[4]);case 6:return new o(a[0],a[1],a[2],a[3],a[4],a[5]);case 7:return new o(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}var f=ci(o.prototype),m=o.apply(f,a);return Ae(m)?m:f}}function ZT(o,a,f){var m=cs(o);function b(){for(var w=arguments.length,x=C(w),E=w,O=di(b);E--;)x[E]=arguments[E];var N=w<3&&x[0]!==O&&x[w-1]!==O?[]:Xn(x,O);if(w-=N.length,w<f)return gg(o,a,$o,b.placeholder,t,x,N,t,t,f-w);var I=this&&this!==Ze&&this instanceof b?m:o;return Et(I,this,x)}return b}function dg(o){return function(a,f,m){var b=Se(a);if(!vt(a)){var w=X(f,3);a=qe(a),f=function(E){return w(b[E],E,b)}}var x=o(a,f,m);return x>-1?b[w?a[x]:x]:t}}function hg(o){return On(function(a){var f=a.length,m=f,b=Vt.prototype.thru;for(o&&a.reverse();m--;){var w=a[m];if(typeof w!="function")throw new $t(l);if(b&&!x&&Ko(w)=="wrapper")var x=new Vt([],!0)}for(m=x?m:f;++m<f;){w=a[m];var E=Ko(w),O=E=="wrapper"?Gc(w):t;O&&Zc(O[0])&&O[1]==(J|L|W|j)&&!O[4].length&&O[9]==1?x=x[Ko(O[0])].apply(x,O[3]):x=w.length==1&&Zc(w)?x[E]():x.thru(w)}return function(){var N=arguments,I=N[0];if(x&&N.length==1&&se(I))return x.plant(I).value();for(var R=0,$=f?a[R].apply(this,N):I;++R<f;)$=a[R].call(this,$);return $}})}function $o(o,a,f,m,b,w,x,E,O,N){var I=a&J,R=a&k,$=a&A,G=a&(L|B),Z=a&V,ce=$?t:cs(o);function ee(){for(var de=arguments.length,pe=C(de),Ct=de;Ct--;)pe[Ct]=arguments[Ct];if(G)var pt=di(ee),Mt=fE(pe,pt);if(m&&(pe=lg(pe,m,b,G)),w&&(pe=ag(pe,w,x,G)),de-=Mt,G&&de<N){var Re=Xn(pe,pt);return gg(o,a,$o,ee.placeholder,f,pe,Re,E,O,N-de)}var tn=R?f:this,Nn=$?tn[o]:o;return de=pe.length,E?pe=bO(pe,E):Z&&de>1&&pe.reverse(),I&&O<de&&(pe.length=O),this&&this!==Ze&&this instanceof ee&&(Nn=ce||cs(Nn)),Nn.apply(tn,pe)}return ee}function pg(o,a){return function(f,m){return OT(f,o,a(m),{})}}function Vo(o,a){return function(f,m){var b;if(f===t&&m===t)return a;if(f!==t&&(b=f),m!==t){if(b===t)return m;typeof f=="string"||typeof m=="string"?(f=Ot(f),m=Ot(m)):(f=Zm(f),m=Zm(m)),b=o(f,m)}return b}}function Kc(o){return On(function(a){return a=Oe(a,Tt(X())),fe(function(f){var m=this;return o(a,function(b){return Et(b,m,f)})})})}function Ho(o,a){a=a===t?" ":Ot(a);var f=a.length;if(f<2)return f?Fc(a,o):a;var m=Fc(a,Co(o/ii(a)));return ri(a)?rr(Xt(m),0,o).join(""):m.slice(0,o)}function eO(o,a,f,m){var b=a&k,w=cs(o);function x(){for(var E=-1,O=arguments.length,N=-1,I=m.length,R=C(I+O),$=this&&this!==Ze&&this instanceof x?w:o;++N<I;)R[N]=m[N];for(;O--;)R[N++]=arguments[++E];return Et($,b?f:this,R)}return x}function mg(o){return function(a,f,m){return m&&typeof m!="number"&&ht(a,f,m)&&(f=m=t),a=Mn(a),f===t?(f=a,a=0):f=Mn(f),m=m===t?a<f?1:-1:Mn(m),zT(a,f,m,o)}}function Uo(o){return function(a,f){return typeof a=="string"&&typeof f=="string"||(a=jt(a),f=jt(f)),o(a,f)}}function gg(o,a,f,m,b,w,x,E,O,N){var I=a&L,R=I?x:t,$=I?t:x,G=I?w:t,Z=I?t:w;a|=I?W:z,a&=~(I?z:W),a&P||(a&=-4);var ce=[o,a,b,G,R,Z,$,E,O,N],ee=f.apply(t,ce);return Zc(o)&&Ag(ee,ce),ee.placeholder=m,Cg(ee,o,a)}function jc(o){var a=ze[o];return function(f,m){if(f=jt(f),m=m==null?0:st(le(m),292),m&&Cm(f)){var b=(_e(f)+"e").split("e"),w=a(b[0]+"e"+(+b[1]+m));return b=(_e(w)+"e").split("e"),+(b[0]+"e"+(+b[1]-m))}return a(f)}}var tO=li&&1/bo(new li([,-0]))[1]==Gt?function(o){return new li(o)}:pu;function yg(o){return function(a){var f=ot(a);return f==Yt?Sc(a):f==Qt?_E(a):uE(a,o(a))}}function Tn(o,a,f,m,b,w,x,E){var O=a&A;if(!O&&typeof o!="function")throw new $t(l);var N=m?m.length:0;if(N||(a&=-97,m=b=t),x=x===t?x:We(le(x),0),E=E===t?E:le(E),N-=b?b.length:0,a&z){var I=m,R=b;m=b=t}var $=O?t:Gc(o),G=[o,a,f,m,b,I,R,w,x,E];if($&&gO(G,$),o=G[0],a=G[1],f=G[2],m=G[3],b=G[4],E=G[9]=G[9]===t?O?0:o.length:We(G[9]-N,0),!E&&a&(L|B)&&(a&=-25),!a||a==k)var Z=XT(o,a,f);else a==L||a==B?Z=ZT(o,a,E):(a==W||a==(k|W))&&!b.length?Z=eO(o,a,f,m):Z=$o.apply(t,G);var ce=$?Qm:Ag;return Cg(ce(Z,G),o,a)}function _g(o,a,f,m){return o===t||en(o,oi[f])&&!be.call(m,f)?a:o}function bg(o,a,f,m,b,w){return Ae(o)&&Ae(a)&&(w.set(a,o),Bo(o,a,t,bg,w),w.delete(a)),o}function nO(o){return ds(o)?t:o}function vg(o,a,f,m,b,w){var x=f&_,E=o.length,O=a.length;if(E!=O&&!(x&&O>E))return!1;var N=w.get(o),I=w.get(a);if(N&&I)return N==a&&I==o;var R=-1,$=!0,G=f&S?new Or:t;for(w.set(o,a),w.set(a,o);++R<E;){var Z=o[R],ce=a[R];if(m)var ee=x?m(ce,Z,R,a,o,w):m(Z,ce,R,o,a,w);if(ee!==t){if(ee)continue;$=!1;break}if(G){if(!gc(a,function(de,pe){if(!Qi(G,pe)&&(Z===de||b(Z,de,f,m,w)))return G.push(pe)})){$=!1;break}}else if(!(Z===ce||b(Z,ce,f,m,w))){$=!1;break}}return w.delete(o),w.delete(a),$}function rO(o,a,f,m,b,w,x){switch(f){case ei:if(o.byteLength!=a.byteLength||o.byteOffset!=a.byteOffset)return!1;o=o.buffer,a=a.buffer;case Yi:return!(o.byteLength!=a.byteLength||!w(new Eo(o),new Eo(a)));case Ne:case Ft:case ji:return en(+o,+a);case Zr:return o.name==a.name&&o.message==a.message;case qi:case Ji:return o==a+"";case Yt:var E=Sc;case Qt:var O=m&_;if(E||(E=bo),o.size!=a.size&&!O)return!1;var N=x.get(o);if(N)return N==a;m|=S,x.set(o,a);var I=vg(E(o),E(a),m,b,w,x);return x.delete(o),I;case ho:if(ns)return ns.call(o)==ns.call(a)}return!1}function iO(o,a,f,m,b,w){var x=f&_,E=qc(o),O=E.length,N=qc(a),I=N.length;if(O!=I&&!x)return!1;for(var R=O;R--;){var $=E[R];if(!(x?$ in a:be.call(a,$)))return!1}var G=w.get(o),Z=w.get(a);if(G&&Z)return G==a&&Z==o;var ce=!0;w.set(o,a),w.set(a,o);for(var ee=x;++R<O;){$=E[R];var de=o[$],pe=a[$];if(m)var Ct=x?m(pe,de,$,a,o,w):m(de,pe,$,o,a,w);if(!(Ct===t?de===pe||b(de,pe,f,m,w):Ct)){ce=!1;break}ee||(ee=$=="constructor")}if(ce&&!ee){var pt=o.constructor,Mt=a.constructor;pt!=Mt&&"constructor"in o&&"constructor"in a&&!(typeof pt=="function"&&pt instanceof pt&&typeof Mt=="function"&&Mt instanceof Mt)&&(ce=!1)}return w.delete(o),w.delete(a),ce}function On(o){return tu(Tg(o,t,Dg),o+"")}function qc(o){return Wm(o,qe,Qc)}function Jc(o){return Wm(o,wt,wg)}var Gc=No?function(o){return No.get(o)}:pu;function Ko(o){for(var a=o.name+"",f=ai[a],m=be.call(ai,a)?f.length:0;m--;){var b=f[m],w=b.func;if(w==null||w==o)return b.name}return a}function di(o){var a=be.call(v,"placeholder")?v:o;return a.placeholder}function X(){var o=v.iteratee||du;return o=o===du?Hm:o,arguments.length?o(arguments[0],arguments[1]):o}function jo(o,a){var f=o.__data__;return dO(a)?f[typeof a=="string"?"string":"hash"]:f.map}function Yc(o){for(var a=qe(o),f=a.length;f--;){var m=a[f],b=o[m];a[f]=[m,b,xg(b)]}return a}function Mr(o,a){var f=mE(o,a);return Vm(f)?f:t}function sO(o){var a=be.call(o,Er),f=o[Er];try{o[Er]=t;var m=!0}catch{}var b=ko.call(o);return m&&(a?o[Er]=f:delete o[Er]),b}var Qc=xc?function(o){return o==null?[]:(o=Se(o),Yn(xc(o),function(a){return Om.call(o,a)}))}:mu,wg=xc?function(o){for(var a=[];o;)Qn(a,Qc(o)),o=To(o);return a}:mu,ot=dt;(Ec&&ot(new Ec(new ArrayBuffer(1)))!=ei||Zi&&ot(new Zi)!=Yt||Tc&&ot(Tc.resolve())!=Bp||li&&ot(new li)!=Qt||es&&ot(new es)!=Gi)&&(ot=function(o){var a=dt(o),f=a==Sn?o.constructor:t,m=f?Nr(f):"";if(m)switch(m){case $E:return ei;case VE:return Yt;case HE:return Bp;case UE:return Qt;case KE:return Gi}return a});function oO(o,a,f){for(var m=-1,b=f.length;++m<b;){var w=f[m],x=w.size;switch(w.type){case"drop":o+=x;break;case"dropRight":a-=x;break;case"take":a=st(a,o+x);break;case"takeRight":o=We(o,a-x);break}}return{start:o,end:a}}function lO(o){var a=o.match(h1);return a?a[1].split(p1):[]}function Sg(o,a,f){a=nr(a,o);for(var m=-1,b=a.length,w=!1;++m<b;){var x=dn(a[m]);if(!(w=o!=null&&f(o,x)))break;o=o[x]}return w||++m!=b?w:(b=o==null?0:o.length,!!b&&Zo(b)&&An(x,b)&&(se(o)||Ir(o)))}function aO(o){var a=o.length,f=new o.constructor(a);return a&&typeof o[0]=="string"&&be.call(o,"index")&&(f.index=o.index,f.input=o.input),f}function kg(o){return typeof o.constructor=="function"&&!us(o)?ci(To(o)):{}}function cO(o,a,f){var m=o.constructor;switch(a){case Yi:return Uc(o);case Ne:case Ft:return new m(+o);case ei:return jT(o,f);case Ya:case Qa:case Xa:case Za:case ec:case tc:case nc:case rc:case ic:return sg(o,f);case Yt:return new m;case ji:case Ji:return new m(o);case qi:return qT(o);case Qt:return new m;case ho:return JT(o)}}function uO(o,a){var f=a.length;if(!f)return o;var m=f-1;return a[m]=(f>1?"& ":"")+a[m],a=a.join(f>2?", ":" "),o.replace(d1,`{
110
+ */ks.exports,function(n,e){(function(){var t,r="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,y=2,g=4,_=1,S=2,k=1,A=2,P=4,L=8,B=16,W=32,z=64,J=128,j=256,V=512,ne=30,ve="...",Le=800,_t=16,Ke=1,Me=2,ft=3,Gt=1/0,wn=9007199254740991,uo=17976931348623157e292,F=NaN,te=4294967295,Ee=te-1,je=te>>>1,cn=[["ary",J],["bind",k],["bindKey",A],["curry",L],["curryRight",B],["flip",V],["partial",W],["partialRight",z],["rearg",j]],Xe="[object Arguments]",Gn="[object Array]",Ui="[object AsyncFunction]",Ne="[object Boolean]",Ft="[object Date]",Ki="[object DOMException]",Zr="[object Error]",fo="[object Function]",Lp="[object GeneratorFunction]",Yt="[object Map]",ji="[object Number]",Yx="[object Null]",Sn="[object Object]",Bp="[object Promise]",Qx="[object Proxy]",qi="[object RegExp]",Qt="[object Set]",Ji="[object String]",ho="[object Symbol]",Xx="[object Undefined]",Gi="[object WeakMap]",Zx="[object WeakSet]",Yi="[object ArrayBuffer]",ei="[object DataView]",Ya="[object Float32Array]",Qa="[object Float64Array]",Xa="[object Int8Array]",Za="[object Int16Array]",ec="[object Int32Array]",tc="[object Uint8Array]",nc="[object Uint8ClampedArray]",rc="[object Uint16Array]",ic="[object Uint32Array]",e1=/\b__p \+= '';/g,t1=/\b(__p \+=) '' \+/g,n1=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fp=/&(?:amp|lt|gt|quot|#39);/g,zp=/[&<>"']/g,r1=RegExp(Fp.source),i1=RegExp(zp.source),s1=/<%-([\s\S]+?)%>/g,o1=/<%([\s\S]+?)%>/g,Wp=/<%=([\s\S]+?)%>/g,l1=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a1=/^\w*$/,c1=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,sc=/[\\^$.*+?()[\]{}|]/g,u1=RegExp(sc.source),oc=/^\s+/,f1=/\s/,d1=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,h1=/\{\n\/\* \[wrapped with (.+)\] \*/,p1=/,? & /,m1=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,g1=/[()=,{}\[\]\/\s]/,y1=/\\(\\)?/g,_1=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,$p=/\w*$/,b1=/^[-+]0x[0-9a-f]+$/i,v1=/^0b[01]+$/i,w1=/^\[object .+?Constructor\]$/,S1=/^0o[0-7]+$/i,k1=/^(?:0|[1-9]\d*)$/,x1=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,po=/($^)/,E1=/['\n\r\u2028\u2029\\]/g,mo="\\ud800-\\udfff",T1="\\u0300-\\u036f",O1="\\ufe20-\\ufe2f",A1="\\u20d0-\\u20ff",Vp=T1+O1+A1,Hp="\\u2700-\\u27bf",Up="a-z\\xdf-\\xf6\\xf8-\\xff",C1="\\xac\\xb1\\xd7\\xf7",M1="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",N1="\\u2000-\\u206f",I1=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Kp="A-Z\\xc0-\\xd6\\xd8-\\xde",jp="\\ufe0e\\ufe0f",qp=C1+M1+N1+I1,lc="['’]",P1="["+mo+"]",Jp="["+qp+"]",go="["+Vp+"]",Gp="\\d+",R1="["+Hp+"]",Yp="["+Up+"]",Qp="[^"+mo+qp+Gp+Hp+Up+Kp+"]",ac="\\ud83c[\\udffb-\\udfff]",D1="(?:"+go+"|"+ac+")",Xp="[^"+mo+"]",cc="(?:\\ud83c[\\udde6-\\uddff]){2}",uc="[\\ud800-\\udbff][\\udc00-\\udfff]",ti="["+Kp+"]",Zp="\\u200d",em="(?:"+Yp+"|"+Qp+")",L1="(?:"+ti+"|"+Qp+")",tm="(?:"+lc+"(?:d|ll|m|re|s|t|ve))?",nm="(?:"+lc+"(?:D|LL|M|RE|S|T|VE))?",rm=D1+"?",im="["+jp+"]?",B1="(?:"+Zp+"(?:"+[Xp,cc,uc].join("|")+")"+im+rm+")*",F1="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",z1="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",sm=im+rm+B1,W1="(?:"+[R1,cc,uc].join("|")+")"+sm,$1="(?:"+[Xp+go+"?",go,cc,uc,P1].join("|")+")",V1=RegExp(lc,"g"),H1=RegExp(go,"g"),fc=RegExp(ac+"(?="+ac+")|"+$1+sm,"g"),U1=RegExp([ti+"?"+Yp+"+"+tm+"(?="+[Jp,ti,"$"].join("|")+")",L1+"+"+nm+"(?="+[Jp,ti+em,"$"].join("|")+")",ti+"?"+em+"+"+tm,ti+"+"+nm,z1,F1,Gp,W1].join("|"),"g"),K1=RegExp("["+Zp+mo+Vp+jp+"]"),j1=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,q1=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],J1=-1,Te={};Te[Ya]=Te[Qa]=Te[Xa]=Te[Za]=Te[ec]=Te[tc]=Te[nc]=Te[rc]=Te[ic]=!0,Te[Xe]=Te[Gn]=Te[Yi]=Te[Ne]=Te[ei]=Te[Ft]=Te[Zr]=Te[fo]=Te[Yt]=Te[ji]=Te[Sn]=Te[qi]=Te[Qt]=Te[Ji]=Te[Gi]=!1;var ke={};ke[Xe]=ke[Gn]=ke[Yi]=ke[ei]=ke[Ne]=ke[Ft]=ke[Ya]=ke[Qa]=ke[Xa]=ke[Za]=ke[ec]=ke[Yt]=ke[ji]=ke[Sn]=ke[qi]=ke[Qt]=ke[Ji]=ke[ho]=ke[tc]=ke[nc]=ke[rc]=ke[ic]=!0,ke[Zr]=ke[fo]=ke[Gi]=!1;var G1={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Y1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Q1={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},X1={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Z1=parseFloat,eE=parseInt,om=typeof mi=="object"&&mi&&mi.Object===Object&&mi,tE=typeof self=="object"&&self&&self.Object===Object&&self,Ze=om||tE||Function("return this")(),dc=e&&!e.nodeType&&e,Er=dc&&!0&&n&&!n.nodeType&&n,lm=Er&&Er.exports===dc,hc=lm&&om.process,zt=function(){try{var T=Er&&Er.require&&Er.require("util").types;return T||hc&&hc.binding&&hc.binding("util")}catch{}}(),am=zt&&zt.isArrayBuffer,cm=zt&&zt.isDate,um=zt&&zt.isMap,fm=zt&&zt.isRegExp,dm=zt&&zt.isSet,hm=zt&&zt.isTypedArray;function Et(T,M,C){switch(C.length){case 0:return T.call(M);case 1:return T.call(M,C[0]);case 2:return T.call(M,C[0],C[1]);case 3:return T.call(M,C[0],C[1],C[2])}return T.apply(M,C)}function nE(T,M,C,U){for(var ie=-1,ye=T==null?0:T.length;++ie<ye;){var ze=T[ie];M(U,ze,C(ze),T)}return U}function Wt(T,M){for(var C=-1,U=T==null?0:T.length;++C<U&&M(T[C],C,T)!==!1;);return T}function rE(T,M){for(var C=T==null?0:T.length;C--&&M(T[C],C,T)!==!1;);return T}function pm(T,M){for(var C=-1,U=T==null?0:T.length;++C<U;)if(!M(T[C],C,T))return!1;return!0}function Yn(T,M){for(var C=-1,U=T==null?0:T.length,ie=0,ye=[];++C<U;){var ze=T[C];M(ze,C,T)&&(ye[ie++]=ze)}return ye}function yo(T,M){var C=T==null?0:T.length;return!!C&&ni(T,M,0)>-1}function pc(T,M,C){for(var U=-1,ie=T==null?0:T.length;++U<ie;)if(C(M,T[U]))return!0;return!1}function Oe(T,M){for(var C=-1,U=T==null?0:T.length,ie=Array(U);++C<U;)ie[C]=M(T[C],C,T);return ie}function Qn(T,M){for(var C=-1,U=M.length,ie=T.length;++C<U;)T[ie+C]=M[C];return T}function mc(T,M,C,U){var ie=-1,ye=T==null?0:T.length;for(U&&ye&&(C=T[++ie]);++ie<ye;)C=M(C,T[ie],ie,T);return C}function iE(T,M,C,U){var ie=T==null?0:T.length;for(U&&ie&&(C=T[--ie]);ie--;)C=M(C,T[ie],ie,T);return C}function gc(T,M){for(var C=-1,U=T==null?0:T.length;++C<U;)if(M(T[C],C,T))return!0;return!1}var sE=yc("length");function oE(T){return T.split("")}function lE(T){return T.match(m1)||[]}function mm(T,M,C){var U;return C(T,function(ie,ye,ze){if(M(ie,ye,ze))return U=ye,!1}),U}function _o(T,M,C,U){for(var ie=T.length,ye=C+(U?1:-1);U?ye--:++ye<ie;)if(M(T[ye],ye,T))return ye;return-1}function ni(T,M,C){return M===M?bE(T,M,C):_o(T,gm,C)}function aE(T,M,C,U){for(var ie=C-1,ye=T.length;++ie<ye;)if(U(T[ie],M))return ie;return-1}function gm(T){return T!==T}function ym(T,M){var C=T==null?0:T.length;return C?bc(T,M)/C:F}function yc(T){return function(M){return M==null?t:M[T]}}function _c(T){return function(M){return T==null?t:T[M]}}function _m(T,M,C,U,ie){return ie(T,function(ye,ze,Se){C=U?(U=!1,ye):M(C,ye,ze,Se)}),C}function cE(T,M){var C=T.length;for(T.sort(M);C--;)T[C]=T[C].value;return T}function bc(T,M){for(var C,U=-1,ie=T.length;++U<ie;){var ye=M(T[U]);ye!==t&&(C=C===t?ye:C+ye)}return C}function vc(T,M){for(var C=-1,U=Array(T);++C<T;)U[C]=M(C);return U}function uE(T,M){return Oe(M,function(C){return[C,T[C]]})}function bm(T){return T&&T.slice(0,km(T)+1).replace(oc,"")}function Tt(T){return function(M){return T(M)}}function wc(T,M){return Oe(M,function(C){return T[C]})}function Qi(T,M){return T.has(M)}function vm(T,M){for(var C=-1,U=T.length;++C<U&&ni(M,T[C],0)>-1;);return C}function wm(T,M){for(var C=T.length;C--&&ni(M,T[C],0)>-1;);return C}function fE(T,M){for(var C=T.length,U=0;C--;)T[C]===M&&++U;return U}var dE=_c(G1),hE=_c(Y1);function pE(T){return"\\"+X1[T]}function mE(T,M){return T==null?t:T[M]}function ri(T){return K1.test(T)}function gE(T){return j1.test(T)}function yE(T){for(var M,C=[];!(M=T.next()).done;)C.push(M.value);return C}function Sc(T){var M=-1,C=Array(T.size);return T.forEach(function(U,ie){C[++M]=[ie,U]}),C}function Sm(T,M){return function(C){return T(M(C))}}function Xn(T,M){for(var C=-1,U=T.length,ie=0,ye=[];++C<U;){var ze=T[C];(ze===M||ze===h)&&(T[C]=h,ye[ie++]=C)}return ye}function bo(T){var M=-1,C=Array(T.size);return T.forEach(function(U){C[++M]=U}),C}function _E(T){var M=-1,C=Array(T.size);return T.forEach(function(U){C[++M]=[U,U]}),C}function bE(T,M,C){for(var U=C-1,ie=T.length;++U<ie;)if(T[U]===M)return U;return-1}function vE(T,M,C){for(var U=C+1;U--;)if(T[U]===M)return U;return U}function ii(T){return ri(T)?SE(T):sE(T)}function Xt(T){return ri(T)?kE(T):oE(T)}function km(T){for(var M=T.length;M--&&f1.test(T.charAt(M)););return M}var wE=_c(Q1);function SE(T){for(var M=fc.lastIndex=0;fc.test(T);)++M;return M}function kE(T){return T.match(fc)||[]}function xE(T){return T.match(U1)||[]}var EE=function T(M){M=M==null?Ze:si.defaults(Ze.Object(),M,si.pick(Ze,q1));var C=M.Array,U=M.Date,ie=M.Error,ye=M.Function,ze=M.Math,Se=M.Object,kc=M.RegExp,TE=M.String,$t=M.TypeError,vo=C.prototype,OE=ye.prototype,oi=Se.prototype,wo=M["__core-js_shared__"],So=OE.toString,be=oi.hasOwnProperty,AE=0,xm=function(){var o=/[^.]+$/.exec(wo&&wo.keys&&wo.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),ko=oi.toString,CE=So.call(Se),ME=Ze._,NE=kc("^"+So.call(be).replace(sc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xo=lm?M.Buffer:t,Zn=M.Symbol,Eo=M.Uint8Array,Em=xo?xo.allocUnsafe:t,To=Sm(Se.getPrototypeOf,Se),Tm=Se.create,Om=oi.propertyIsEnumerable,Oo=vo.splice,Am=Zn?Zn.isConcatSpreadable:t,Xi=Zn?Zn.iterator:t,Tr=Zn?Zn.toStringTag:t,Ao=function(){try{var o=Nr(Se,"defineProperty");return o({},"",{}),o}catch{}}(),IE=M.clearTimeout!==Ze.clearTimeout&&M.clearTimeout,PE=U&&U.now!==Ze.Date.now&&U.now,RE=M.setTimeout!==Ze.setTimeout&&M.setTimeout,Co=ze.ceil,Mo=ze.floor,xc=Se.getOwnPropertySymbols,DE=xo?xo.isBuffer:t,Cm=M.isFinite,LE=vo.join,BE=Sm(Se.keys,Se),We=ze.max,st=ze.min,FE=U.now,zE=M.parseInt,Mm=ze.random,WE=vo.reverse,Ec=Nr(M,"DataView"),Zi=Nr(M,"Map"),Tc=Nr(M,"Promise"),li=Nr(M,"Set"),es=Nr(M,"WeakMap"),ts=Nr(Se,"create"),No=es&&new es,ai={},$E=Ir(Ec),VE=Ir(Zi),HE=Ir(Tc),UE=Ir(li),KE=Ir(es),Io=Zn?Zn.prototype:t,ns=Io?Io.valueOf:t,Nm=Io?Io.toString:t;function v(o){if(Ie(o)&&!se(o)&&!(o instanceof he)){if(o instanceof Vt)return o;if(be.call(o,"__wrapped__"))return Ig(o)}return new Vt(o)}var ci=function(){function o(){}return function(a){if(!Ae(a))return{};if(Tm)return Tm(a);o.prototype=a;var f=new o;return o.prototype=t,f}}();function Po(){}function Vt(o,a){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!a,this.__index__=0,this.__values__=t}v.templateSettings={escape:s1,evaluate:o1,interpolate:Wp,variable:"",imports:{_:v}},v.prototype=Po.prototype,v.prototype.constructor=v,Vt.prototype=ci(Po.prototype),Vt.prototype.constructor=Vt;function he(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=te,this.__views__=[]}function jE(){var o=new he(this.__wrapped__);return o.__actions__=bt(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=bt(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=bt(this.__views__),o}function qE(){if(this.__filtered__){var o=new he(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function JE(){var o=this.__wrapped__.value(),a=this.__dir__,f=se(o),m=a<0,b=f?o.length:0,w=oO(0,b,this.__views__),x=w.start,E=w.end,O=E-x,N=m?E:x-1,I=this.__iteratees__,R=I.length,$=0,G=st(O,this.__takeCount__);if(!f||!m&&b==O&&G==O)return tg(o,this.__actions__);var Z=[];e:for(;O--&&$<G;){N+=a;for(var ce=-1,ee=o[N];++ce<R;){var de=I[ce],pe=de.iteratee,Ct=de.type,pt=pe(ee);if(Ct==Me)ee=pt;else if(!pt){if(Ct==Ke)continue e;break e}}Z[$++]=ee}return Z}he.prototype=ci(Po.prototype),he.prototype.constructor=he;function Or(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function GE(){this.__data__=ts?ts(null):{},this.size=0}function YE(o){var a=this.has(o)&&delete this.__data__[o];return this.size-=a?1:0,a}function QE(o){var a=this.__data__;if(ts){var f=a[o];return f===u?t:f}return be.call(a,o)?a[o]:t}function XE(o){var a=this.__data__;return ts?a[o]!==t:be.call(a,o)}function ZE(o,a){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=ts&&a===t?u:a,this}Or.prototype.clear=GE,Or.prototype.delete=YE,Or.prototype.get=QE,Or.prototype.has=XE,Or.prototype.set=ZE;function kn(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function eT(){this.__data__=[],this.size=0}function tT(o){var a=this.__data__,f=Ro(a,o);if(f<0)return!1;var m=a.length-1;return f==m?a.pop():Oo.call(a,f,1),--this.size,!0}function nT(o){var a=this.__data__,f=Ro(a,o);return f<0?t:a[f][1]}function rT(o){return Ro(this.__data__,o)>-1}function iT(o,a){var f=this.__data__,m=Ro(f,o);return m<0?(++this.size,f.push([o,a])):f[m][1]=a,this}kn.prototype.clear=eT,kn.prototype.delete=tT,kn.prototype.get=nT,kn.prototype.has=rT,kn.prototype.set=iT;function xn(o){var a=-1,f=o==null?0:o.length;for(this.clear();++a<f;){var m=o[a];this.set(m[0],m[1])}}function sT(){this.size=0,this.__data__={hash:new Or,map:new(Zi||kn),string:new Or}}function oT(o){var a=jo(this,o).delete(o);return this.size-=a?1:0,a}function lT(o){return jo(this,o).get(o)}function aT(o){return jo(this,o).has(o)}function cT(o,a){var f=jo(this,o),m=f.size;return f.set(o,a),this.size+=f.size==m?0:1,this}xn.prototype.clear=sT,xn.prototype.delete=oT,xn.prototype.get=lT,xn.prototype.has=aT,xn.prototype.set=cT;function Ar(o){var a=-1,f=o==null?0:o.length;for(this.__data__=new xn;++a<f;)this.add(o[a])}function uT(o){return this.__data__.set(o,u),this}function fT(o){return this.__data__.has(o)}Ar.prototype.add=Ar.prototype.push=uT,Ar.prototype.has=fT;function Zt(o){var a=this.__data__=new kn(o);this.size=a.size}function dT(){this.__data__=new kn,this.size=0}function hT(o){var a=this.__data__,f=a.delete(o);return this.size=a.size,f}function pT(o){return this.__data__.get(o)}function mT(o){return this.__data__.has(o)}function gT(o,a){var f=this.__data__;if(f instanceof kn){var m=f.__data__;if(!Zi||m.length<i-1)return m.push([o,a]),this.size=++f.size,this;f=this.__data__=new xn(m)}return f.set(o,a),this.size=f.size,this}Zt.prototype.clear=dT,Zt.prototype.delete=hT,Zt.prototype.get=pT,Zt.prototype.has=mT,Zt.prototype.set=gT;function Im(o,a){var f=se(o),m=!f&&Pr(o),b=!f&&!m&&ir(o),w=!f&&!m&&!b&&hi(o),x=f||m||b||w,E=x?vc(o.length,TE):[],O=E.length;for(var N in o)(a||be.call(o,N))&&!(x&&(N=="length"||b&&(N=="offset"||N=="parent")||w&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||An(N,O)))&&E.push(N);return E}function Pm(o){var a=o.length;return a?o[Bc(0,a-1)]:t}function yT(o,a){return qo(bt(o),Cr(a,0,o.length))}function _T(o){return qo(bt(o))}function Oc(o,a,f){(f!==t&&!en(o[a],f)||f===t&&!(a in o))&&En(o,a,f)}function rs(o,a,f){var m=o[a];(!(be.call(o,a)&&en(m,f))||f===t&&!(a in o))&&En(o,a,f)}function Ro(o,a){for(var f=o.length;f--;)if(en(o[f][0],a))return f;return-1}function bT(o,a,f,m){return er(o,function(b,w,x){a(m,b,f(b),x)}),m}function Rm(o,a){return o&&fn(a,qe(a),o)}function vT(o,a){return o&&fn(a,wt(a),o)}function En(o,a,f){a=="__proto__"&&Ao?Ao(o,a,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[a]=f}function Ac(o,a){for(var f=-1,m=a.length,b=C(m),w=o==null;++f<m;)b[f]=w?t:au(o,a[f]);return b}function Cr(o,a,f){return o===o&&(f!==t&&(o=o<=f?o:f),a!==t&&(o=o>=a?o:a)),o}function Ht(o,a,f,m,b,w){var x,E=a&p,O=a&y,N=a&g;if(f&&(x=b?f(o,m,b,w):f(o)),x!==t)return x;if(!Ae(o))return o;var I=se(o);if(I){if(x=aO(o),!E)return bt(o,x)}else{var R=ot(o),$=R==fo||R==Lp;if(ir(o))return ig(o,E);if(R==Sn||R==Xe||$&&!b){if(x=O||$?{}:kg(o),!E)return O?QT(o,vT(x,o)):YT(o,Rm(x,o))}else{if(!ke[R])return b?o:{};x=cO(o,R,E)}}w||(w=new Zt);var G=w.get(o);if(G)return G;w.set(o,x),Xg(o)?o.forEach(function(ee){x.add(Ht(ee,a,f,ee,o,w))}):Yg(o)&&o.forEach(function(ee,de){x.set(de,Ht(ee,a,f,de,o,w))});var Z=N?O?Jc:qc:O?wt:qe,ce=I?t:Z(o);return Wt(ce||o,function(ee,de){ce&&(de=ee,ee=o[de]),rs(x,de,Ht(ee,a,f,de,o,w))}),x}function wT(o){var a=qe(o);return function(f){return Dm(f,o,a)}}function Dm(o,a,f){var m=f.length;if(o==null)return!m;for(o=Se(o);m--;){var b=f[m],w=a[b],x=o[b];if(x===t&&!(b in o)||!w(x))return!1}return!0}function Lm(o,a,f){if(typeof o!="function")throw new $t(l);return fs(function(){o.apply(t,f)},a)}function is(o,a,f,m){var b=-1,w=yo,x=!0,E=o.length,O=[],N=a.length;if(!E)return O;f&&(a=Oe(a,Tt(f))),m?(w=pc,x=!1):a.length>=i&&(w=Qi,x=!1,a=new Ar(a));e:for(;++b<E;){var I=o[b],R=f==null?I:f(I);if(I=m||I!==0?I:0,x&&R===R){for(var $=N;$--;)if(a[$]===R)continue e;O.push(I)}else w(a,R,m)||O.push(I)}return O}var er=cg(un),Bm=cg(Mc,!0);function ST(o,a){var f=!0;return er(o,function(m,b,w){return f=!!a(m,b,w),f}),f}function Do(o,a,f){for(var m=-1,b=o.length;++m<b;){var w=o[m],x=a(w);if(x!=null&&(E===t?x===x&&!At(x):f(x,E)))var E=x,O=w}return O}function kT(o,a,f,m){var b=o.length;for(f=le(f),f<0&&(f=-f>b?0:b+f),m=m===t||m>b?b:le(m),m<0&&(m+=b),m=f>m?0:ey(m);f<m;)o[f++]=a;return o}function Fm(o,a){var f=[];return er(o,function(m,b,w){a(m,b,w)&&f.push(m)}),f}function et(o,a,f,m,b){var w=-1,x=o.length;for(f||(f=fO),b||(b=[]);++w<x;){var E=o[w];a>0&&f(E)?a>1?et(E,a-1,f,m,b):Qn(b,E):m||(b[b.length]=E)}return b}var Cc=ug(),zm=ug(!0);function un(o,a){return o&&Cc(o,a,qe)}function Mc(o,a){return o&&zm(o,a,qe)}function Lo(o,a){return Yn(a,function(f){return Cn(o[f])})}function Mr(o,a){a=nr(a,o);for(var f=0,m=a.length;o!=null&&f<m;)o=o[dn(a[f++])];return f&&f==m?o:t}function Wm(o,a,f){var m=a(o);return se(o)?m:Qn(m,f(o))}function dt(o){return o==null?o===t?Xx:Yx:Tr&&Tr in Se(o)?sO(o):_O(o)}function Nc(o,a){return o>a}function xT(o,a){return o!=null&&be.call(o,a)}function ET(o,a){return o!=null&&a in Se(o)}function TT(o,a,f){return o>=st(a,f)&&o<We(a,f)}function Ic(o,a,f){for(var m=f?pc:yo,b=o[0].length,w=o.length,x=w,E=C(w),O=1/0,N=[];x--;){var I=o[x];x&&a&&(I=Oe(I,Tt(a))),O=st(I.length,O),E[x]=!f&&(a||b>=120&&I.length>=120)?new Ar(x&&I):t}I=o[0];var R=-1,$=E[0];e:for(;++R<b&&N.length<O;){var G=I[R],Z=a?a(G):G;if(G=f||G!==0?G:0,!($?Qi($,Z):m(N,Z,f))){for(x=w;--x;){var ce=E[x];if(!(ce?Qi(ce,Z):m(o[x],Z,f)))continue e}$&&$.push(Z),N.push(G)}}return N}function OT(o,a,f,m){return un(o,function(b,w,x){a(m,f(b),w,x)}),m}function ss(o,a,f){a=nr(a,o),o=Og(o,a);var m=o==null?o:o[dn(Kt(a))];return m==null?t:Et(m,o,f)}function $m(o){return Ie(o)&&dt(o)==Xe}function AT(o){return Ie(o)&&dt(o)==Yi}function CT(o){return Ie(o)&&dt(o)==Ft}function ls(o,a,f,m,b){return o===a?!0:o==null||a==null||!Ie(o)&&!Ie(a)?o!==o&&a!==a:MT(o,a,f,m,ls,b)}function MT(o,a,f,m,b,w){var x=se(o),E=se(a),O=x?Gn:ot(o),N=E?Gn:ot(a);O=O==Xe?Sn:O,N=N==Xe?Sn:N;var I=O==Sn,R=N==Sn,$=O==N;if($&&ir(o)){if(!ir(a))return!1;x=!0,I=!1}if($&&!I)return w||(w=new Zt),x||hi(o)?vg(o,a,f,m,b,w):rO(o,a,O,f,m,b,w);if(!(f&_)){var G=I&&be.call(o,"__wrapped__"),Z=R&&be.call(a,"__wrapped__");if(G||Z){var ce=G?o.value():o,ee=Z?a.value():a;return w||(w=new Zt),b(ce,ee,f,m,w)}}return $?(w||(w=new Zt),iO(o,a,f,m,b,w)):!1}function NT(o){return Ie(o)&&ot(o)==Yt}function Pc(o,a,f,m){var b=f.length,w=b,x=!m;if(o==null)return!w;for(o=Se(o);b--;){var E=f[b];if(x&&E[2]?E[1]!==o[E[0]]:!(E[0]in o))return!1}for(;++b<w;){E=f[b];var O=E[0],N=o[O],I=E[1];if(x&&E[2]){if(N===t&&!(O in o))return!1}else{var R=new Zt;if(m)var $=m(N,I,O,o,a,R);if(!($===t?ls(I,N,_|S,m,R):$))return!1}}return!0}function Vm(o){if(!Ae(o)||hO(o))return!1;var a=Cn(o)?NE:w1;return a.test(Ir(o))}function IT(o){return Ie(o)&&dt(o)==qi}function PT(o){return Ie(o)&&ot(o)==Qt}function RT(o){return Ie(o)&&Zo(o.length)&&!!Te[dt(o)]}function Hm(o){return typeof o=="function"?o:o==null?St:typeof o=="object"?se(o)?jm(o[0],o[1]):Km(o):fy(o)}function Rc(o){if(!us(o))return BE(o);var a=[];for(var f in Se(o))be.call(o,f)&&f!="constructor"&&a.push(f);return a}function DT(o){if(!Ae(o))return yO(o);var a=us(o),f=[];for(var m in o)m=="constructor"&&(a||!be.call(o,m))||f.push(m);return f}function Dc(o,a){return o<a}function Um(o,a){var f=-1,m=vt(o)?C(o.length):[];return er(o,function(b,w,x){m[++f]=a(b,w,x)}),m}function Km(o){var a=Yc(o);return a.length==1&&a[0][2]?Eg(a[0][0],a[0][1]):function(f){return f===o||Pc(f,o,a)}}function jm(o,a){return Xc(o)&&xg(a)?Eg(dn(o),a):function(f){var m=au(f,o);return m===t&&m===a?cu(f,o):ls(a,m,_|S)}}function Bo(o,a,f,m,b){o!==a&&Cc(a,function(w,x){if(b||(b=new Zt),Ae(w))LT(o,a,x,f,Bo,m,b);else{var E=m?m(eu(o,x),w,x+"",o,a,b):t;E===t&&(E=w),Oc(o,x,E)}},wt)}function LT(o,a,f,m,b,w,x){var E=eu(o,f),O=eu(a,f),N=x.get(O);if(N){Oc(o,f,N);return}var I=w?w(E,O,f+"",o,a,x):t,R=I===t;if(R){var $=se(O),G=!$&&ir(O),Z=!$&&!G&&hi(O);I=O,$||G||Z?se(E)?I=E:Pe(E)?I=bt(E):G?(R=!1,I=ig(O,!0)):Z?(R=!1,I=sg(O,!0)):I=[]:ds(O)||Pr(O)?(I=E,Pr(E)?I=ty(E):(!Ae(E)||Cn(E))&&(I=kg(O))):R=!1}R&&(x.set(O,I),b(I,O,m,w,x),x.delete(O)),Oc(o,f,I)}function qm(o,a){var f=o.length;if(f)return a+=a<0?f:0,An(a,f)?o[a]:t}function Jm(o,a,f){a.length?a=Oe(a,function(w){return se(w)?function(x){return Mr(x,w.length===1?w[0]:w)}:w}):a=[St];var m=-1;a=Oe(a,Tt(X()));var b=Um(o,function(w,x,E){var O=Oe(a,function(N){return N(w)});return{criteria:O,index:++m,value:w}});return cE(b,function(w,x){return GT(w,x,f)})}function BT(o,a){return Gm(o,a,function(f,m){return cu(o,m)})}function Gm(o,a,f){for(var m=-1,b=a.length,w={};++m<b;){var x=a[m],E=Mr(o,x);f(E,x)&&as(w,nr(x,o),E)}return w}function FT(o){return function(a){return Mr(a,o)}}function Lc(o,a,f,m){var b=m?aE:ni,w=-1,x=a.length,E=o;for(o===a&&(a=bt(a)),f&&(E=Oe(o,Tt(f)));++w<x;)for(var O=0,N=a[w],I=f?f(N):N;(O=b(E,I,O,m))>-1;)E!==o&&Oo.call(E,O,1),Oo.call(o,O,1);return o}function Ym(o,a){for(var f=o?a.length:0,m=f-1;f--;){var b=a[f];if(f==m||b!==w){var w=b;An(b)?Oo.call(o,b,1):Wc(o,b)}}return o}function Bc(o,a){return o+Mo(Mm()*(a-o+1))}function zT(o,a,f,m){for(var b=-1,w=We(Co((a-o)/(f||1)),0),x=C(w);w--;)x[m?w:++b]=o,o+=f;return x}function Fc(o,a){var f="";if(!o||a<1||a>wn)return f;do a%2&&(f+=o),a=Mo(a/2),a&&(o+=o);while(a);return f}function fe(o,a){return tu(Tg(o,a,St),o+"")}function WT(o){return Pm(pi(o))}function $T(o,a){var f=pi(o);return qo(f,Cr(a,0,f.length))}function as(o,a,f,m){if(!Ae(o))return o;a=nr(a,o);for(var b=-1,w=a.length,x=w-1,E=o;E!=null&&++b<w;){var O=dn(a[b]),N=f;if(O==="__proto__"||O==="constructor"||O==="prototype")return o;if(b!=x){var I=E[O];N=m?m(I,O,E):t,N===t&&(N=Ae(I)?I:An(a[b+1])?[]:{})}rs(E,O,N),E=E[O]}return o}var Qm=No?function(o,a){return No.set(o,a),o}:St,VT=Ao?function(o,a){return Ao(o,"toString",{configurable:!0,enumerable:!1,value:fu(a),writable:!0})}:St;function HT(o){return qo(pi(o))}function Ut(o,a,f){var m=-1,b=o.length;a<0&&(a=-a>b?0:b+a),f=f>b?b:f,f<0&&(f+=b),b=a>f?0:f-a>>>0,a>>>=0;for(var w=C(b);++m<b;)w[m]=o[m+a];return w}function UT(o,a){var f;return er(o,function(m,b,w){return f=a(m,b,w),!f}),!!f}function Fo(o,a,f){var m=0,b=o==null?m:o.length;if(typeof a=="number"&&a===a&&b<=je){for(;m<b;){var w=m+b>>>1,x=o[w];x!==null&&!At(x)&&(f?x<=a:x<a)?m=w+1:b=w}return b}return zc(o,a,St,f)}function zc(o,a,f,m){var b=0,w=o==null?0:o.length;if(w===0)return 0;a=f(a);for(var x=a!==a,E=a===null,O=At(a),N=a===t;b<w;){var I=Mo((b+w)/2),R=f(o[I]),$=R!==t,G=R===null,Z=R===R,ce=At(R);if(x)var ee=m||Z;else N?ee=Z&&(m||$):E?ee=Z&&$&&(m||!G):O?ee=Z&&$&&!G&&(m||!ce):G||ce?ee=!1:ee=m?R<=a:R<a;ee?b=I+1:w=I}return st(w,Ee)}function Xm(o,a){for(var f=-1,m=o.length,b=0,w=[];++f<m;){var x=o[f],E=a?a(x):x;if(!f||!en(E,O)){var O=E;w[b++]=x===0?0:x}}return w}function Zm(o){return typeof o=="number"?o:At(o)?F:+o}function Ot(o){if(typeof o=="string")return o;if(se(o))return Oe(o,Ot)+"";if(At(o))return Nm?Nm.call(o):"";var a=o+"";return a=="0"&&1/o==-1/0?"-0":a}function tr(o,a,f){var m=-1,b=yo,w=o.length,x=!0,E=[],O=E;if(f)x=!1,b=pc;else if(w>=i){var N=a?null:tO(o);if(N)return bo(N);x=!1,b=Qi,O=new Ar}else O=a?[]:E;e:for(;++m<w;){var I=o[m],R=a?a(I):I;if(I=f||I!==0?I:0,x&&R===R){for(var $=O.length;$--;)if(O[$]===R)continue e;a&&O.push(R),E.push(I)}else b(O,R,f)||(O!==E&&O.push(R),E.push(I))}return E}function Wc(o,a){return a=nr(a,o),o=Og(o,a),o==null||delete o[dn(Kt(a))]}function eg(o,a,f,m){return as(o,a,f(Mr(o,a)),m)}function zo(o,a,f,m){for(var b=o.length,w=m?b:-1;(m?w--:++w<b)&&a(o[w],w,o););return f?Ut(o,m?0:w,m?w+1:b):Ut(o,m?w+1:0,m?b:w)}function tg(o,a){var f=o;return f instanceof he&&(f=f.value()),mc(a,function(m,b){return b.func.apply(b.thisArg,Qn([m],b.args))},f)}function $c(o,a,f){var m=o.length;if(m<2)return m?tr(o[0]):[];for(var b=-1,w=C(m);++b<m;)for(var x=o[b],E=-1;++E<m;)E!=b&&(w[b]=is(w[b]||x,o[E],a,f));return tr(et(w,1),a,f)}function ng(o,a,f){for(var m=-1,b=o.length,w=a.length,x={};++m<b;){var E=m<w?a[m]:t;f(x,o[m],E)}return x}function Vc(o){return Pe(o)?o:[]}function Hc(o){return typeof o=="function"?o:St}function nr(o,a){return se(o)?o:Xc(o,a)?[o]:Ng(_e(o))}var KT=fe;function rr(o,a,f){var m=o.length;return f=f===t?m:f,!a&&f>=m?o:Ut(o,a,f)}var rg=IE||function(o){return Ze.clearTimeout(o)};function ig(o,a){if(a)return o.slice();var f=o.length,m=Em?Em(f):new o.constructor(f);return o.copy(m),m}function Uc(o){var a=new o.constructor(o.byteLength);return new Eo(a).set(new Eo(o)),a}function jT(o,a){var f=a?Uc(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.byteLength)}function qT(o){var a=new o.constructor(o.source,$p.exec(o));return a.lastIndex=o.lastIndex,a}function JT(o){return ns?Se(ns.call(o)):{}}function sg(o,a){var f=a?Uc(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.length)}function og(o,a){if(o!==a){var f=o!==t,m=o===null,b=o===o,w=At(o),x=a!==t,E=a===null,O=a===a,N=At(a);if(!E&&!N&&!w&&o>a||w&&x&&O&&!E&&!N||m&&x&&O||!f&&O||!b)return 1;if(!m&&!w&&!N&&o<a||N&&f&&b&&!m&&!w||E&&f&&b||!x&&b||!O)return-1}return 0}function GT(o,a,f){for(var m=-1,b=o.criteria,w=a.criteria,x=b.length,E=f.length;++m<x;){var O=og(b[m],w[m]);if(O){if(m>=E)return O;var N=f[m];return O*(N=="desc"?-1:1)}}return o.index-a.index}function lg(o,a,f,m){for(var b=-1,w=o.length,x=f.length,E=-1,O=a.length,N=We(w-x,0),I=C(O+N),R=!m;++E<O;)I[E]=a[E];for(;++b<x;)(R||b<w)&&(I[f[b]]=o[b]);for(;N--;)I[E++]=o[b++];return I}function ag(o,a,f,m){for(var b=-1,w=o.length,x=-1,E=f.length,O=-1,N=a.length,I=We(w-E,0),R=C(I+N),$=!m;++b<I;)R[b]=o[b];for(var G=b;++O<N;)R[G+O]=a[O];for(;++x<E;)($||b<w)&&(R[G+f[x]]=o[b++]);return R}function bt(o,a){var f=-1,m=o.length;for(a||(a=C(m));++f<m;)a[f]=o[f];return a}function fn(o,a,f,m){var b=!f;f||(f={});for(var w=-1,x=a.length;++w<x;){var E=a[w],O=m?m(f[E],o[E],E,f,o):t;O===t&&(O=o[E]),b?En(f,E,O):rs(f,E,O)}return f}function YT(o,a){return fn(o,Qc(o),a)}function QT(o,a){return fn(o,wg(o),a)}function Wo(o,a){return function(f,m){var b=se(f)?nE:bT,w=a?a():{};return b(f,o,X(m,2),w)}}function ui(o){return fe(function(a,f){var m=-1,b=f.length,w=b>1?f[b-1]:t,x=b>2?f[2]:t;for(w=o.length>3&&typeof w=="function"?(b--,w):t,x&&ht(f[0],f[1],x)&&(w=b<3?t:w,b=1),a=Se(a);++m<b;){var E=f[m];E&&o(a,E,m,w)}return a})}function cg(o,a){return function(f,m){if(f==null)return f;if(!vt(f))return o(f,m);for(var b=f.length,w=a?b:-1,x=Se(f);(a?w--:++w<b)&&m(x[w],w,x)!==!1;);return f}}function ug(o){return function(a,f,m){for(var b=-1,w=Se(a),x=m(a),E=x.length;E--;){var O=x[o?E:++b];if(f(w[O],O,w)===!1)break}return a}}function XT(o,a,f){var m=a&k,b=cs(o);function w(){var x=this&&this!==Ze&&this instanceof w?b:o;return x.apply(m?f:this,arguments)}return w}function fg(o){return function(a){a=_e(a);var f=ri(a)?Xt(a):t,m=f?f[0]:a.charAt(0),b=f?rr(f,1).join(""):a.slice(1);return m[o]()+b}}function fi(o){return function(a){return mc(cy(ay(a).replace(V1,"")),o,"")}}function cs(o){return function(){var a=arguments;switch(a.length){case 0:return new o;case 1:return new o(a[0]);case 2:return new o(a[0],a[1]);case 3:return new o(a[0],a[1],a[2]);case 4:return new o(a[0],a[1],a[2],a[3]);case 5:return new o(a[0],a[1],a[2],a[3],a[4]);case 6:return new o(a[0],a[1],a[2],a[3],a[4],a[5]);case 7:return new o(a[0],a[1],a[2],a[3],a[4],a[5],a[6])}var f=ci(o.prototype),m=o.apply(f,a);return Ae(m)?m:f}}function ZT(o,a,f){var m=cs(o);function b(){for(var w=arguments.length,x=C(w),E=w,O=di(b);E--;)x[E]=arguments[E];var N=w<3&&x[0]!==O&&x[w-1]!==O?[]:Xn(x,O);if(w-=N.length,w<f)return gg(o,a,$o,b.placeholder,t,x,N,t,t,f-w);var I=this&&this!==Ze&&this instanceof b?m:o;return Et(I,this,x)}return b}function dg(o){return function(a,f,m){var b=Se(a);if(!vt(a)){var w=X(f,3);a=qe(a),f=function(E){return w(b[E],E,b)}}var x=o(a,f,m);return x>-1?b[w?a[x]:x]:t}}function hg(o){return On(function(a){var f=a.length,m=f,b=Vt.prototype.thru;for(o&&a.reverse();m--;){var w=a[m];if(typeof w!="function")throw new $t(l);if(b&&!x&&Ko(w)=="wrapper")var x=new Vt([],!0)}for(m=x?m:f;++m<f;){w=a[m];var E=Ko(w),O=E=="wrapper"?Gc(w):t;O&&Zc(O[0])&&O[1]==(J|L|W|j)&&!O[4].length&&O[9]==1?x=x[Ko(O[0])].apply(x,O[3]):x=w.length==1&&Zc(w)?x[E]():x.thru(w)}return function(){var N=arguments,I=N[0];if(x&&N.length==1&&se(I))return x.plant(I).value();for(var R=0,$=f?a[R].apply(this,N):I;++R<f;)$=a[R].call(this,$);return $}})}function $o(o,a,f,m,b,w,x,E,O,N){var I=a&J,R=a&k,$=a&A,G=a&(L|B),Z=a&V,ce=$?t:cs(o);function ee(){for(var de=arguments.length,pe=C(de),Ct=de;Ct--;)pe[Ct]=arguments[Ct];if(G)var pt=di(ee),Mt=fE(pe,pt);if(m&&(pe=lg(pe,m,b,G)),w&&(pe=ag(pe,w,x,G)),de-=Mt,G&&de<N){var Re=Xn(pe,pt);return gg(o,a,$o,ee.placeholder,f,pe,Re,E,O,N-de)}var tn=R?f:this,Nn=$?tn[o]:o;return de=pe.length,E?pe=bO(pe,E):Z&&de>1&&pe.reverse(),I&&O<de&&(pe.length=O),this&&this!==Ze&&this instanceof ee&&(Nn=ce||cs(Nn)),Nn.apply(tn,pe)}return ee}function pg(o,a){return function(f,m){return OT(f,o,a(m),{})}}function Vo(o,a){return function(f,m){var b;if(f===t&&m===t)return a;if(f!==t&&(b=f),m!==t){if(b===t)return m;typeof f=="string"||typeof m=="string"?(f=Ot(f),m=Ot(m)):(f=Zm(f),m=Zm(m)),b=o(f,m)}return b}}function Kc(o){return On(function(a){return a=Oe(a,Tt(X())),fe(function(f){var m=this;return o(a,function(b){return Et(b,m,f)})})})}function Ho(o,a){a=a===t?" ":Ot(a);var f=a.length;if(f<2)return f?Fc(a,o):a;var m=Fc(a,Co(o/ii(a)));return ri(a)?rr(Xt(m),0,o).join(""):m.slice(0,o)}function eO(o,a,f,m){var b=a&k,w=cs(o);function x(){for(var E=-1,O=arguments.length,N=-1,I=m.length,R=C(I+O),$=this&&this!==Ze&&this instanceof x?w:o;++N<I;)R[N]=m[N];for(;O--;)R[N++]=arguments[++E];return Et($,b?f:this,R)}return x}function mg(o){return function(a,f,m){return m&&typeof m!="number"&&ht(a,f,m)&&(f=m=t),a=Mn(a),f===t?(f=a,a=0):f=Mn(f),m=m===t?a<f?1:-1:Mn(m),zT(a,f,m,o)}}function Uo(o){return function(a,f){return typeof a=="string"&&typeof f=="string"||(a=jt(a),f=jt(f)),o(a,f)}}function gg(o,a,f,m,b,w,x,E,O,N){var I=a&L,R=I?x:t,$=I?t:x,G=I?w:t,Z=I?t:w;a|=I?W:z,a&=~(I?z:W),a&P||(a&=-4);var ce=[o,a,b,G,R,Z,$,E,O,N],ee=f.apply(t,ce);return Zc(o)&&Ag(ee,ce),ee.placeholder=m,Cg(ee,o,a)}function jc(o){var a=ze[o];return function(f,m){if(f=jt(f),m=m==null?0:st(le(m),292),m&&Cm(f)){var b=(_e(f)+"e").split("e"),w=a(b[0]+"e"+(+b[1]+m));return b=(_e(w)+"e").split("e"),+(b[0]+"e"+(+b[1]-m))}return a(f)}}var tO=li&&1/bo(new li([,-0]))[1]==Gt?function(o){return new li(o)}:pu;function yg(o){return function(a){var f=ot(a);return f==Yt?Sc(a):f==Qt?_E(a):uE(a,o(a))}}function Tn(o,a,f,m,b,w,x,E){var O=a&A;if(!O&&typeof o!="function")throw new $t(l);var N=m?m.length:0;if(N||(a&=-97,m=b=t),x=x===t?x:We(le(x),0),E=E===t?E:le(E),N-=b?b.length:0,a&z){var I=m,R=b;m=b=t}var $=O?t:Gc(o),G=[o,a,f,m,b,I,R,w,x,E];if($&&gO(G,$),o=G[0],a=G[1],f=G[2],m=G[3],b=G[4],E=G[9]=G[9]===t?O?0:o.length:We(G[9]-N,0),!E&&a&(L|B)&&(a&=-25),!a||a==k)var Z=XT(o,a,f);else a==L||a==B?Z=ZT(o,a,E):(a==W||a==(k|W))&&!b.length?Z=eO(o,a,f,m):Z=$o.apply(t,G);var ce=$?Qm:Ag;return Cg(ce(Z,G),o,a)}function _g(o,a,f,m){return o===t||en(o,oi[f])&&!be.call(m,f)?a:o}function bg(o,a,f,m,b,w){return Ae(o)&&Ae(a)&&(w.set(a,o),Bo(o,a,t,bg,w),w.delete(a)),o}function nO(o){return ds(o)?t:o}function vg(o,a,f,m,b,w){var x=f&_,E=o.length,O=a.length;if(E!=O&&!(x&&O>E))return!1;var N=w.get(o),I=w.get(a);if(N&&I)return N==a&&I==o;var R=-1,$=!0,G=f&S?new Ar:t;for(w.set(o,a),w.set(a,o);++R<E;){var Z=o[R],ce=a[R];if(m)var ee=x?m(ce,Z,R,a,o,w):m(Z,ce,R,o,a,w);if(ee!==t){if(ee)continue;$=!1;break}if(G){if(!gc(a,function(de,pe){if(!Qi(G,pe)&&(Z===de||b(Z,de,f,m,w)))return G.push(pe)})){$=!1;break}}else if(!(Z===ce||b(Z,ce,f,m,w))){$=!1;break}}return w.delete(o),w.delete(a),$}function rO(o,a,f,m,b,w,x){switch(f){case ei:if(o.byteLength!=a.byteLength||o.byteOffset!=a.byteOffset)return!1;o=o.buffer,a=a.buffer;case Yi:return!(o.byteLength!=a.byteLength||!w(new Eo(o),new Eo(a)));case Ne:case Ft:case ji:return en(+o,+a);case Zr:return o.name==a.name&&o.message==a.message;case qi:case Ji:return o==a+"";case Yt:var E=Sc;case Qt:var O=m&_;if(E||(E=bo),o.size!=a.size&&!O)return!1;var N=x.get(o);if(N)return N==a;m|=S,x.set(o,a);var I=vg(E(o),E(a),m,b,w,x);return x.delete(o),I;case ho:if(ns)return ns.call(o)==ns.call(a)}return!1}function iO(o,a,f,m,b,w){var x=f&_,E=qc(o),O=E.length,N=qc(a),I=N.length;if(O!=I&&!x)return!1;for(var R=O;R--;){var $=E[R];if(!(x?$ in a:be.call(a,$)))return!1}var G=w.get(o),Z=w.get(a);if(G&&Z)return G==a&&Z==o;var ce=!0;w.set(o,a),w.set(a,o);for(var ee=x;++R<O;){$=E[R];var de=o[$],pe=a[$];if(m)var Ct=x?m(pe,de,$,a,o,w):m(de,pe,$,o,a,w);if(!(Ct===t?de===pe||b(de,pe,f,m,w):Ct)){ce=!1;break}ee||(ee=$=="constructor")}if(ce&&!ee){var pt=o.constructor,Mt=a.constructor;pt!=Mt&&"constructor"in o&&"constructor"in a&&!(typeof pt=="function"&&pt instanceof pt&&typeof Mt=="function"&&Mt instanceof Mt)&&(ce=!1)}return w.delete(o),w.delete(a),ce}function On(o){return tu(Tg(o,t,Dg),o+"")}function qc(o){return Wm(o,qe,Qc)}function Jc(o){return Wm(o,wt,wg)}var Gc=No?function(o){return No.get(o)}:pu;function Ko(o){for(var a=o.name+"",f=ai[a],m=be.call(ai,a)?f.length:0;m--;){var b=f[m],w=b.func;if(w==null||w==o)return b.name}return a}function di(o){var a=be.call(v,"placeholder")?v:o;return a.placeholder}function X(){var o=v.iteratee||du;return o=o===du?Hm:o,arguments.length?o(arguments[0],arguments[1]):o}function jo(o,a){var f=o.__data__;return dO(a)?f[typeof a=="string"?"string":"hash"]:f.map}function Yc(o){for(var a=qe(o),f=a.length;f--;){var m=a[f],b=o[m];a[f]=[m,b,xg(b)]}return a}function Nr(o,a){var f=mE(o,a);return Vm(f)?f:t}function sO(o){var a=be.call(o,Tr),f=o[Tr];try{o[Tr]=t;var m=!0}catch{}var b=ko.call(o);return m&&(a?o[Tr]=f:delete o[Tr]),b}var Qc=xc?function(o){return o==null?[]:(o=Se(o),Yn(xc(o),function(a){return Om.call(o,a)}))}:mu,wg=xc?function(o){for(var a=[];o;)Qn(a,Qc(o)),o=To(o);return a}:mu,ot=dt;(Ec&&ot(new Ec(new ArrayBuffer(1)))!=ei||Zi&&ot(new Zi)!=Yt||Tc&&ot(Tc.resolve())!=Bp||li&&ot(new li)!=Qt||es&&ot(new es)!=Gi)&&(ot=function(o){var a=dt(o),f=a==Sn?o.constructor:t,m=f?Ir(f):"";if(m)switch(m){case $E:return ei;case VE:return Yt;case HE:return Bp;case UE:return Qt;case KE:return Gi}return a});function oO(o,a,f){for(var m=-1,b=f.length;++m<b;){var w=f[m],x=w.size;switch(w.type){case"drop":o+=x;break;case"dropRight":a-=x;break;case"take":a=st(a,o+x);break;case"takeRight":o=We(o,a-x);break}}return{start:o,end:a}}function lO(o){var a=o.match(h1);return a?a[1].split(p1):[]}function Sg(o,a,f){a=nr(a,o);for(var m=-1,b=a.length,w=!1;++m<b;){var x=dn(a[m]);if(!(w=o!=null&&f(o,x)))break;o=o[x]}return w||++m!=b?w:(b=o==null?0:o.length,!!b&&Zo(b)&&An(x,b)&&(se(o)||Pr(o)))}function aO(o){var a=o.length,f=new o.constructor(a);return a&&typeof o[0]=="string"&&be.call(o,"index")&&(f.index=o.index,f.input=o.input),f}function kg(o){return typeof o.constructor=="function"&&!us(o)?ci(To(o)):{}}function cO(o,a,f){var m=o.constructor;switch(a){case Yi:return Uc(o);case Ne:case Ft:return new m(+o);case ei:return jT(o,f);case Ya:case Qa:case Xa:case Za:case ec:case tc:case nc:case rc:case ic:return sg(o,f);case Yt:return new m;case ji:case Ji:return new m(o);case qi:return qT(o);case Qt:return new m;case ho:return JT(o)}}function uO(o,a){var f=a.length;if(!f)return o;var m=f-1;return a[m]=(f>1?"& ":"")+a[m],a=a.join(f>2?", ":" "),o.replace(d1,`{
109
111
  /* [wrapped with `+a+`] */
110
- `)}function fO(o){return se(o)||Ir(o)||!!(Am&&o&&o[Am])}function An(o,a){var f=typeof o;return a=a??wn,!!a&&(f=="number"||f!="symbol"&&k1.test(o))&&o>-1&&o%1==0&&o<a}function ht(o,a,f){if(!Ae(f))return!1;var m=typeof a;return(m=="number"?vt(f)&&An(a,f.length):m=="string"&&a in f)?en(f[a],o):!1}function Xc(o,a){if(se(o))return!1;var f=typeof o;return f=="number"||f=="symbol"||f=="boolean"||o==null||At(o)?!0:a1.test(o)||!l1.test(o)||a!=null&&o in Se(a)}function dO(o){var a=typeof o;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?o!=="__proto__":o===null}function Zc(o){var a=Ko(o),f=v[a];if(typeof f!="function"||!(a in he.prototype))return!1;if(o===f)return!0;var m=Gc(f);return!!m&&o===m[0]}function hO(o){return!!xm&&xm in o}var pO=wo?Cn:gu;function us(o){var a=o&&o.constructor,f=typeof a=="function"&&a.prototype||oi;return o===f}function xg(o){return o===o&&!Ae(o)}function Eg(o,a){return function(f){return f==null?!1:f[o]===a&&(a!==t||o in Se(f))}}function mO(o){var a=Qo(o,function(m){return f.size===d&&f.clear(),m}),f=a.cache;return a}function gO(o,a){var f=o[1],m=a[1],b=f|m,w=b<(k|A|J),x=m==J&&f==L||m==J&&f==j&&o[7].length<=a[8]||m==(J|j)&&a[7].length<=a[8]&&f==L;if(!(w||x))return o;m&k&&(o[2]=a[2],b|=f&k?0:P);var E=a[3];if(E){var O=o[3];o[3]=O?lg(O,E,a[4]):E,o[4]=O?Xn(o[3],h):a[4]}return E=a[5],E&&(O=o[5],o[5]=O?ag(O,E,a[6]):E,o[6]=O?Xn(o[5],h):a[6]),E=a[7],E&&(o[7]=E),m&J&&(o[8]=o[8]==null?a[8]:st(o[8],a[8])),o[9]==null&&(o[9]=a[9]),o[0]=a[0],o[1]=b,o}function yO(o){var a=[];if(o!=null)for(var f in Se(o))a.push(f);return a}function _O(o){return ko.call(o)}function Tg(o,a,f){return a=We(a===t?o.length-1:a,0),function(){for(var m=arguments,b=-1,w=We(m.length-a,0),x=C(w);++b<w;)x[b]=m[a+b];b=-1;for(var E=C(a+1);++b<a;)E[b]=m[b];return E[a]=f(x),Et(o,this,E)}}function Og(o,a){return a.length<2?o:Cr(o,Ut(a,0,-1))}function bO(o,a){for(var f=o.length,m=st(a.length,f),b=bt(o);m--;){var w=a[m];o[m]=An(w,f)?b[w]:t}return o}function eu(o,a){if(!(a==="constructor"&&typeof o[a]=="function")&&a!="__proto__")return o[a]}var Ag=Mg(Qm),fs=RE||function(o,a){return Ze.setTimeout(o,a)},tu=Mg(VT);function Cg(o,a,f){var m=a+"";return tu(o,uO(m,vO(lO(m),f)))}function Mg(o){var a=0,f=0;return function(){var m=FE(),b=_t-(m-f);if(f=m,b>0){if(++a>=Le)return arguments[0]}else a=0;return o.apply(t,arguments)}}function qo(o,a){var f=-1,m=o.length,b=m-1;for(a=a===t?m:a;++f<a;){var w=Bc(f,b),x=o[w];o[w]=o[f],o[f]=x}return o.length=a,o}var Ng=mO(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(c1,function(f,m,b,w){a.push(b?w.replace(y1,"$1"):m||f)}),a});function dn(o){if(typeof o=="string"||At(o))return o;var a=o+"";return a=="0"&&1/o==-1/0?"-0":a}function Nr(o){if(o!=null){try{return So.call(o)}catch{}try{return o+""}catch{}}return""}function vO(o,a){return Wt(cn,function(f){var m="_."+f[0];a&f[1]&&!yo(o,m)&&o.push(m)}),o.sort()}function Ig(o){if(o instanceof he)return o.clone();var a=new Vt(o.__wrapped__,o.__chain__);return a.__actions__=bt(o.__actions__),a.__index__=o.__index__,a.__values__=o.__values__,a}function wO(o,a,f){(f?ht(o,a,f):a===t)?a=1:a=We(le(a),0);var m=o==null?0:o.length;if(!m||a<1)return[];for(var b=0,w=0,x=C(Co(m/a));b<m;)x[w++]=Ut(o,b,b+=a);return x}function SO(o){for(var a=-1,f=o==null?0:o.length,m=0,b=[];++a<f;){var w=o[a];w&&(b[m++]=w)}return b}function kO(){var o=arguments.length;if(!o)return[];for(var a=C(o-1),f=arguments[0],m=o;m--;)a[m-1]=arguments[m];return Qn(se(f)?bt(f):[f],et(a,1))}var xO=fe(function(o,a){return Pe(o)?is(o,et(a,1,Pe,!0)):[]}),EO=fe(function(o,a){var f=Kt(a);return Pe(f)&&(f=t),Pe(o)?is(o,et(a,1,Pe,!0),X(f,2)):[]}),TO=fe(function(o,a){var f=Kt(a);return Pe(f)&&(f=t),Pe(o)?is(o,et(a,1,Pe,!0),t,f):[]});function OO(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),Ut(o,a<0?0:a,m)):[]}function AO(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),a=m-a,Ut(o,0,a<0?0:a)):[]}function CO(o,a){return o&&o.length?zo(o,X(a,3),!0,!0):[]}function MO(o,a){return o&&o.length?zo(o,X(a,3),!0):[]}function NO(o,a,f,m){var b=o==null?0:o.length;return b?(f&&typeof f!="number"&&ht(o,a,f)&&(f=0,m=b),kT(o,a,f,m)):[]}function Pg(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:le(f);return b<0&&(b=We(m+b,0)),_o(o,X(a,3),b)}function Rg(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=m-1;return f!==t&&(b=le(f),b=f<0?We(m+b,0):st(b,m-1)),_o(o,X(a,3),b,!0)}function Dg(o){var a=o==null?0:o.length;return a?et(o,1):[]}function IO(o){var a=o==null?0:o.length;return a?et(o,Gt):[]}function PO(o,a){var f=o==null?0:o.length;return f?(a=a===t?1:le(a),et(o,a)):[]}function RO(o){for(var a=-1,f=o==null?0:o.length,m={};++a<f;){var b=o[a];m[b[0]]=b[1]}return m}function Lg(o){return o&&o.length?o[0]:t}function DO(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:le(f);return b<0&&(b=We(m+b,0)),ni(o,a,b)}function LO(o){var a=o==null?0:o.length;return a?Ut(o,0,-1):[]}var BO=fe(function(o){var a=Oe(o,Vc);return a.length&&a[0]===o[0]?Ic(a):[]}),FO=fe(function(o){var a=Kt(o),f=Oe(o,Vc);return a===Kt(f)?a=t:f.pop(),f.length&&f[0]===o[0]?Ic(f,X(a,2)):[]}),zO=fe(function(o){var a=Kt(o),f=Oe(o,Vc);return a=typeof a=="function"?a:t,a&&f.pop(),f.length&&f[0]===o[0]?Ic(f,t,a):[]});function WO(o,a){return o==null?"":LE.call(o,a)}function Kt(o){var a=o==null?0:o.length;return a?o[a-1]:t}function $O(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=m;return f!==t&&(b=le(f),b=b<0?We(m+b,0):st(b,m-1)),a===a?vE(o,a,b):_o(o,gm,b,!0)}function VO(o,a){return o&&o.length?qm(o,le(a)):t}var HO=fe(Bg);function Bg(o,a){return o&&o.length&&a&&a.length?Lc(o,a):o}function UO(o,a,f){return o&&o.length&&a&&a.length?Lc(o,a,X(f,2)):o}function KO(o,a,f){return o&&o.length&&a&&a.length?Lc(o,a,t,f):o}var jO=On(function(o,a){var f=o==null?0:o.length,m=Ac(o,a);return Ym(o,Oe(a,function(b){return An(b,f)?+b:b}).sort(og)),m});function qO(o,a){var f=[];if(!(o&&o.length))return f;var m=-1,b=[],w=o.length;for(a=X(a,3);++m<w;){var x=o[m];a(x,m,o)&&(f.push(x),b.push(m))}return Ym(o,b),f}function nu(o){return o==null?o:WE.call(o)}function JO(o,a,f){var m=o==null?0:o.length;return m?(f&&typeof f!="number"&&ht(o,a,f)?(a=0,f=m):(a=a==null?0:le(a),f=f===t?m:le(f)),Ut(o,a,f)):[]}function GO(o,a){return Fo(o,a)}function YO(o,a,f){return zc(o,a,X(f,2))}function QO(o,a){var f=o==null?0:o.length;if(f){var m=Fo(o,a);if(m<f&&en(o[m],a))return m}return-1}function XO(o,a){return Fo(o,a,!0)}function ZO(o,a,f){return zc(o,a,X(f,2),!0)}function eA(o,a){var f=o==null?0:o.length;if(f){var m=Fo(o,a,!0)-1;if(en(o[m],a))return m}return-1}function tA(o){return o&&o.length?Xm(o):[]}function nA(o,a){return o&&o.length?Xm(o,X(a,2)):[]}function rA(o){var a=o==null?0:o.length;return a?Ut(o,1,a):[]}function iA(o,a,f){return o&&o.length?(a=f||a===t?1:le(a),Ut(o,0,a<0?0:a)):[]}function sA(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),a=m-a,Ut(o,a<0?0:a,m)):[]}function oA(o,a){return o&&o.length?zo(o,X(a,3),!1,!0):[]}function lA(o,a){return o&&o.length?zo(o,X(a,3)):[]}var aA=fe(function(o){return tr(et(o,1,Pe,!0))}),cA=fe(function(o){var a=Kt(o);return Pe(a)&&(a=t),tr(et(o,1,Pe,!0),X(a,2))}),uA=fe(function(o){var a=Kt(o);return a=typeof a=="function"?a:t,tr(et(o,1,Pe,!0),t,a)});function fA(o){return o&&o.length?tr(o):[]}function dA(o,a){return o&&o.length?tr(o,X(a,2)):[]}function hA(o,a){return a=typeof a=="function"?a:t,o&&o.length?tr(o,t,a):[]}function ru(o){if(!(o&&o.length))return[];var a=0;return o=Yn(o,function(f){if(Pe(f))return a=We(f.length,a),!0}),vc(a,function(f){return Oe(o,yc(f))})}function Fg(o,a){if(!(o&&o.length))return[];var f=ru(o);return a==null?f:Oe(f,function(m){return Et(a,t,m)})}var pA=fe(function(o,a){return Pe(o)?is(o,a):[]}),mA=fe(function(o){return $c(Yn(o,Pe))}),gA=fe(function(o){var a=Kt(o);return Pe(a)&&(a=t),$c(Yn(o,Pe),X(a,2))}),yA=fe(function(o){var a=Kt(o);return a=typeof a=="function"?a:t,$c(Yn(o,Pe),t,a)}),_A=fe(ru);function bA(o,a){return ng(o||[],a||[],rs)}function vA(o,a){return ng(o||[],a||[],as)}var wA=fe(function(o){var a=o.length,f=a>1?o[a-1]:t;return f=typeof f=="function"?(o.pop(),f):t,Fg(o,f)});function zg(o){var a=v(o);return a.__chain__=!0,a}function SA(o,a){return a(o),o}function Jo(o,a){return a(o)}var kA=On(function(o){var a=o.length,f=a?o[0]:0,m=this.__wrapped__,b=function(w){return Ac(w,o)};return a>1||this.__actions__.length||!(m instanceof he)||!An(f)?this.thru(b):(m=m.slice(f,+f+(a?1:0)),m.__actions__.push({func:Jo,args:[b],thisArg:t}),new Vt(m,this.__chain__).thru(function(w){return a&&!w.length&&w.push(t),w}))});function xA(){return zg(this)}function EA(){return new Vt(this.value(),this.__chain__)}function TA(){this.__values__===t&&(this.__values__=Zg(this.value()));var o=this.__index__>=this.__values__.length,a=o?t:this.__values__[this.__index__++];return{done:o,value:a}}function OA(){return this}function AA(o){for(var a,f=this;f instanceof Po;){var m=Ig(f);m.__index__=0,m.__values__=t,a?b.__wrapped__=m:a=m;var b=m;f=f.__wrapped__}return b.__wrapped__=o,a}function CA(){var o=this.__wrapped__;if(o instanceof he){var a=o;return this.__actions__.length&&(a=new he(this)),a=a.reverse(),a.__actions__.push({func:Jo,args:[nu],thisArg:t}),new Vt(a,this.__chain__)}return this.thru(nu)}function MA(){return tg(this.__wrapped__,this.__actions__)}var NA=Wo(function(o,a,f){be.call(o,f)?++o[f]:En(o,f,1)});function IA(o,a,f){var m=se(o)?pm:ST;return f&&ht(o,a,f)&&(a=t),m(o,X(a,3))}function PA(o,a){var f=se(o)?Yn:Fm;return f(o,X(a,3))}var RA=dg(Pg),DA=dg(Rg);function LA(o,a){return et(Go(o,a),1)}function BA(o,a){return et(Go(o,a),Gt)}function FA(o,a,f){return f=f===t?1:le(f),et(Go(o,a),f)}function Wg(o,a){var f=se(o)?Wt:er;return f(o,X(a,3))}function $g(o,a){var f=se(o)?rE:Bm;return f(o,X(a,3))}var zA=Wo(function(o,a,f){be.call(o,f)?o[f].push(a):En(o,f,[a])});function WA(o,a,f,m){o=vt(o)?o:pi(o),f=f&&!m?le(f):0;var b=o.length;return f<0&&(f=We(b+f,0)),el(o)?f<=b&&o.indexOf(a,f)>-1:!!b&&ni(o,a,f)>-1}var $A=fe(function(o,a,f){var m=-1,b=typeof a=="function",w=vt(o)?C(o.length):[];return er(o,function(x){w[++m]=b?Et(a,x,f):ss(x,a,f)}),w}),VA=Wo(function(o,a,f){En(o,f,a)});function Go(o,a){var f=se(o)?Oe:Um;return f(o,X(a,3))}function HA(o,a,f,m){return o==null?[]:(se(a)||(a=a==null?[]:[a]),f=m?t:f,se(f)||(f=f==null?[]:[f]),Jm(o,a,f))}var UA=Wo(function(o,a,f){o[f?0:1].push(a)},function(){return[[],[]]});function KA(o,a,f){var m=se(o)?mc:_m,b=arguments.length<3;return m(o,X(a,4),f,b,er)}function jA(o,a,f){var m=se(o)?iE:_m,b=arguments.length<3;return m(o,X(a,4),f,b,Bm)}function qA(o,a){var f=se(o)?Yn:Fm;return f(o,Xo(X(a,3)))}function JA(o){var a=se(o)?Pm:WT;return a(o)}function GA(o,a,f){(f?ht(o,a,f):a===t)?a=1:a=le(a);var m=se(o)?yT:$T;return m(o,a)}function YA(o){var a=se(o)?_T:HT;return a(o)}function QA(o){if(o==null)return 0;if(vt(o))return el(o)?ii(o):o.length;var a=ot(o);return a==Yt||a==Qt?o.size:Rc(o).length}function XA(o,a,f){var m=se(o)?gc:UT;return f&&ht(o,a,f)&&(a=t),m(o,X(a,3))}var ZA=fe(function(o,a){if(o==null)return[];var f=a.length;return f>1&&ht(o,a[0],a[1])?a=[]:f>2&&ht(a[0],a[1],a[2])&&(a=[a[0]]),Jm(o,et(a,1),[])}),Yo=PE||function(){return Ze.Date.now()};function eC(o,a){if(typeof a!="function")throw new $t(l);return o=le(o),function(){if(--o<1)return a.apply(this,arguments)}}function Vg(o,a,f){return a=f?t:a,a=o&&a==null?o.length:a,Tn(o,J,t,t,t,t,a)}function Hg(o,a){var f;if(typeof a!="function")throw new $t(l);return o=le(o),function(){return--o>0&&(f=a.apply(this,arguments)),o<=1&&(a=t),f}}var iu=fe(function(o,a,f){var m=k;if(f.length){var b=Xn(f,di(iu));m|=W}return Tn(o,m,a,f,b)}),Ug=fe(function(o,a,f){var m=k|A;if(f.length){var b=Xn(f,di(Ug));m|=W}return Tn(a,m,o,f,b)});function Kg(o,a,f){a=f?t:a;var m=Tn(o,L,t,t,t,t,t,a);return m.placeholder=Kg.placeholder,m}function jg(o,a,f){a=f?t:a;var m=Tn(o,B,t,t,t,t,t,a);return m.placeholder=jg.placeholder,m}function qg(o,a,f){var m,b,w,x,E,O,N=0,I=!1,R=!1,$=!0;if(typeof o!="function")throw new $t(l);a=jt(a)||0,Ae(f)&&(I=!!f.leading,R="maxWait"in f,w=R?We(jt(f.maxWait)||0,a):w,$="trailing"in f?!!f.trailing:$);function G(Re){var tn=m,Nn=b;return m=b=t,N=Re,x=o.apply(Nn,tn),x}function Z(Re){return N=Re,E=fs(de,a),I?G(Re):x}function ce(Re){var tn=Re-O,Nn=Re-N,dy=a-tn;return R?st(dy,w-Nn):dy}function ee(Re){var tn=Re-O,Nn=Re-N;return O===t||tn>=a||tn<0||R&&Nn>=w}function de(){var Re=Yo();if(ee(Re))return pe(Re);E=fs(de,ce(Re))}function pe(Re){return E=t,$&&m?G(Re):(m=b=t,x)}function Ct(){E!==t&&rg(E),N=0,m=O=b=E=t}function pt(){return E===t?x:pe(Yo())}function Mt(){var Re=Yo(),tn=ee(Re);if(m=arguments,b=this,O=Re,tn){if(E===t)return Z(O);if(R)return rg(E),E=fs(de,a),G(O)}return E===t&&(E=fs(de,a)),x}return Mt.cancel=Ct,Mt.flush=pt,Mt}var tC=fe(function(o,a){return Lm(o,1,a)}),nC=fe(function(o,a,f){return Lm(o,jt(a)||0,f)});function rC(o){return Tn(o,V)}function Qo(o,a){if(typeof o!="function"||a!=null&&typeof a!="function")throw new $t(l);var f=function(){var m=arguments,b=a?a.apply(this,m):m[0],w=f.cache;if(w.has(b))return w.get(b);var x=o.apply(this,m);return f.cache=w.set(b,x)||w,x};return f.cache=new(Qo.Cache||xn),f}Qo.Cache=xn;function Xo(o){if(typeof o!="function")throw new $t(l);return function(){var a=arguments;switch(a.length){case 0:return!o.call(this);case 1:return!o.call(this,a[0]);case 2:return!o.call(this,a[0],a[1]);case 3:return!o.call(this,a[0],a[1],a[2])}return!o.apply(this,a)}}function iC(o){return Hg(2,o)}var sC=KT(function(o,a){a=a.length==1&&se(a[0])?Oe(a[0],Tt(X())):Oe(et(a,1),Tt(X()));var f=a.length;return fe(function(m){for(var b=-1,w=st(m.length,f);++b<w;)m[b]=a[b].call(this,m[b]);return Et(o,this,m)})}),su=fe(function(o,a){var f=Xn(a,di(su));return Tn(o,W,t,a,f)}),Jg=fe(function(o,a){var f=Xn(a,di(Jg));return Tn(o,z,t,a,f)}),oC=On(function(o,a){return Tn(o,j,t,t,t,a)});function lC(o,a){if(typeof o!="function")throw new $t(l);return a=a===t?a:le(a),fe(o,a)}function aC(o,a){if(typeof o!="function")throw new $t(l);return a=a==null?0:We(le(a),0),fe(function(f){var m=f[a],b=rr(f,0,a);return m&&Qn(b,m),Et(o,this,b)})}function cC(o,a,f){var m=!0,b=!0;if(typeof o!="function")throw new $t(l);return Ae(f)&&(m="leading"in f?!!f.leading:m,b="trailing"in f?!!f.trailing:b),qg(o,a,{leading:m,maxWait:a,trailing:b})}function uC(o){return Vg(o,1)}function fC(o,a){return su(Hc(a),o)}function dC(){if(!arguments.length)return[];var o=arguments[0];return se(o)?o:[o]}function hC(o){return Ht(o,g)}function pC(o,a){return a=typeof a=="function"?a:t,Ht(o,g,a)}function mC(o){return Ht(o,p|g)}function gC(o,a){return a=typeof a=="function"?a:t,Ht(o,p|g,a)}function yC(o,a){return a==null||Dm(o,a,qe(a))}function en(o,a){return o===a||o!==o&&a!==a}var _C=Uo(Nc),bC=Uo(function(o,a){return o>=a}),Ir=$m(function(){return arguments}())?$m:function(o){return Ie(o)&&be.call(o,"callee")&&!Om.call(o,"callee")},se=C.isArray,vC=am?Tt(am):AT;function vt(o){return o!=null&&Zo(o.length)&&!Cn(o)}function Pe(o){return Ie(o)&&vt(o)}function wC(o){return o===!0||o===!1||Ie(o)&&dt(o)==Ne}var ir=DE||gu,SC=cm?Tt(cm):CT;function kC(o){return Ie(o)&&o.nodeType===1&&!ds(o)}function xC(o){if(o==null)return!0;if(vt(o)&&(se(o)||typeof o=="string"||typeof o.splice=="function"||ir(o)||hi(o)||Ir(o)))return!o.length;var a=ot(o);if(a==Yt||a==Qt)return!o.size;if(us(o))return!Rc(o).length;for(var f in o)if(be.call(o,f))return!1;return!0}function EC(o,a){return ls(o,a)}function TC(o,a,f){f=typeof f=="function"?f:t;var m=f?f(o,a):t;return m===t?ls(o,a,t,f):!!m}function ou(o){if(!Ie(o))return!1;var a=dt(o);return a==Zr||a==Ki||typeof o.message=="string"&&typeof o.name=="string"&&!ds(o)}function OC(o){return typeof o=="number"&&Cm(o)}function Cn(o){if(!Ae(o))return!1;var a=dt(o);return a==fo||a==Lp||a==Ui||a==Qx}function Gg(o){return typeof o=="number"&&o==le(o)}function Zo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=wn}function Ae(o){var a=typeof o;return o!=null&&(a=="object"||a=="function")}function Ie(o){return o!=null&&typeof o=="object"}var Yg=um?Tt(um):NT;function AC(o,a){return o===a||Pc(o,a,Yc(a))}function CC(o,a,f){return f=typeof f=="function"?f:t,Pc(o,a,Yc(a),f)}function MC(o){return Qg(o)&&o!=+o}function NC(o){if(pO(o))throw new ie(s);return Vm(o)}function IC(o){return o===null}function PC(o){return o==null}function Qg(o){return typeof o=="number"||Ie(o)&&dt(o)==ji}function ds(o){if(!Ie(o)||dt(o)!=Sn)return!1;var a=To(o);if(a===null)return!0;var f=be.call(a,"constructor")&&a.constructor;return typeof f=="function"&&f instanceof f&&So.call(f)==CE}var lu=fm?Tt(fm):IT;function RC(o){return Gg(o)&&o>=-9007199254740991&&o<=wn}var Xg=dm?Tt(dm):PT;function el(o){return typeof o=="string"||!se(o)&&Ie(o)&&dt(o)==Ji}function At(o){return typeof o=="symbol"||Ie(o)&&dt(o)==ho}var hi=hm?Tt(hm):RT;function DC(o){return o===t}function LC(o){return Ie(o)&&ot(o)==Gi}function BC(o){return Ie(o)&&dt(o)==Zx}var FC=Uo(Dc),zC=Uo(function(o,a){return o<=a});function Zg(o){if(!o)return[];if(vt(o))return el(o)?Xt(o):bt(o);if(Xi&&o[Xi])return yE(o[Xi]());var a=ot(o),f=a==Yt?Sc:a==Qt?bo:pi;return f(o)}function Mn(o){if(!o)return o===0?o:0;if(o=jt(o),o===Gt||o===-1/0){var a=o<0?-1:1;return a*uo}return o===o?o:0}function le(o){var a=Mn(o),f=a%1;return a===a?f?a-f:a:0}function ey(o){return o?Ar(le(o),0,te):0}function jt(o){if(typeof o=="number")return o;if(At(o))return F;if(Ae(o)){var a=typeof o.valueOf=="function"?o.valueOf():o;o=Ae(a)?a+"":a}if(typeof o!="string")return o===0?o:+o;o=bm(o);var f=v1.test(o);return f||S1.test(o)?eE(o.slice(2),f?2:8):b1.test(o)?F:+o}function ty(o){return fn(o,wt(o))}function WC(o){return o?Ar(le(o),-9007199254740991,wn):o===0?o:0}function _e(o){return o==null?"":Ot(o)}var $C=ui(function(o,a){if(us(a)||vt(a)){fn(a,qe(a),o);return}for(var f in a)be.call(a,f)&&rs(o,f,a[f])}),ny=ui(function(o,a){fn(a,wt(a),o)}),tl=ui(function(o,a,f,m){fn(a,wt(a),o,m)}),VC=ui(function(o,a,f,m){fn(a,qe(a),o,m)}),HC=On(Ac);function UC(o,a){var f=ci(o);return a==null?f:Rm(f,a)}var KC=fe(function(o,a){o=Se(o);var f=-1,m=a.length,b=m>2?a[2]:t;for(b&&ht(a[0],a[1],b)&&(m=1);++f<m;)for(var w=a[f],x=wt(w),E=-1,O=x.length;++E<O;){var N=x[E],I=o[N];(I===t||en(I,oi[N])&&!be.call(o,N))&&(o[N]=w[N])}return o}),jC=fe(function(o){return o.push(t,bg),Et(ry,t,o)});function qC(o,a){return mm(o,X(a,3),un)}function JC(o,a){return mm(o,X(a,3),Mc)}function GC(o,a){return o==null?o:Cc(o,X(a,3),wt)}function YC(o,a){return o==null?o:zm(o,X(a,3),wt)}function QC(o,a){return o&&un(o,X(a,3))}function XC(o,a){return o&&Mc(o,X(a,3))}function ZC(o){return o==null?[]:Lo(o,qe(o))}function eM(o){return o==null?[]:Lo(o,wt(o))}function au(o,a,f){var m=o==null?t:Cr(o,a);return m===t?f:m}function tM(o,a){return o!=null&&Sg(o,a,xT)}function cu(o,a){return o!=null&&Sg(o,a,ET)}var nM=pg(function(o,a,f){a!=null&&typeof a.toString!="function"&&(a=ko.call(a)),o[a]=f},fu(St)),rM=pg(function(o,a,f){a!=null&&typeof a.toString!="function"&&(a=ko.call(a)),be.call(o,a)?o[a].push(f):o[a]=[f]},X),iM=fe(ss);function qe(o){return vt(o)?Im(o):Rc(o)}function wt(o){return vt(o)?Im(o,!0):DT(o)}function sM(o,a){var f={};return a=X(a,3),un(o,function(m,b,w){En(f,a(m,b,w),m)}),f}function oM(o,a){var f={};return a=X(a,3),un(o,function(m,b,w){En(f,b,a(m,b,w))}),f}var lM=ui(function(o,a,f){Bo(o,a,f)}),ry=ui(function(o,a,f,m){Bo(o,a,f,m)}),aM=On(function(o,a){var f={};if(o==null)return f;var m=!1;a=Oe(a,function(w){return w=nr(w,o),m||(m=w.length>1),w}),fn(o,Jc(o),f),m&&(f=Ht(f,p|y|g,nO));for(var b=a.length;b--;)Wc(f,a[b]);return f});function cM(o,a){return iy(o,Xo(X(a)))}var uM=On(function(o,a){return o==null?{}:BT(o,a)});function iy(o,a){if(o==null)return{};var f=Oe(Jc(o),function(m){return[m]});return a=X(a),Gm(o,f,function(m,b){return a(m,b[0])})}function fM(o,a,f){a=nr(a,o);var m=-1,b=a.length;for(b||(b=1,o=t);++m<b;){var w=o==null?t:o[dn(a[m])];w===t&&(m=b,w=f),o=Cn(w)?w.call(o):w}return o}function dM(o,a,f){return o==null?o:as(o,a,f)}function hM(o,a,f,m){return m=typeof m=="function"?m:t,o==null?o:as(o,a,f,m)}var sy=yg(qe),oy=yg(wt);function pM(o,a,f){var m=se(o),b=m||ir(o)||hi(o);if(a=X(a,4),f==null){var w=o&&o.constructor;b?f=m?new w:[]:Ae(o)?f=Cn(w)?ci(To(o)):{}:f={}}return(b?Wt:un)(o,function(x,E,O){return a(f,x,E,O)}),f}function mM(o,a){return o==null?!0:Wc(o,a)}function gM(o,a,f){return o==null?o:eg(o,a,Hc(f))}function yM(o,a,f,m){return m=typeof m=="function"?m:t,o==null?o:eg(o,a,Hc(f),m)}function pi(o){return o==null?[]:wc(o,qe(o))}function _M(o){return o==null?[]:wc(o,wt(o))}function bM(o,a,f){return f===t&&(f=a,a=t),f!==t&&(f=jt(f),f=f===f?f:0),a!==t&&(a=jt(a),a=a===a?a:0),Ar(jt(o),a,f)}function vM(o,a,f){return a=Mn(a),f===t?(f=a,a=0):f=Mn(f),o=jt(o),TT(o,a,f)}function wM(o,a,f){if(f&&typeof f!="boolean"&&ht(o,a,f)&&(a=f=t),f===t&&(typeof a=="boolean"?(f=a,a=t):typeof o=="boolean"&&(f=o,o=t)),o===t&&a===t?(o=0,a=1):(o=Mn(o),a===t?(a=o,o=0):a=Mn(a)),o>a){var m=o;o=a,a=m}if(f||o%1||a%1){var b=Mm();return st(o+b*(a-o+Z1("1e-"+((b+"").length-1))),a)}return Bc(o,a)}var SM=fi(function(o,a,f){return a=a.toLowerCase(),o+(f?ly(a):a)});function ly(o){return uu(_e(o).toLowerCase())}function ay(o){return o=_e(o),o&&o.replace(x1,dE).replace(H1,"")}function kM(o,a,f){o=_e(o),a=Ot(a);var m=o.length;f=f===t?m:Ar(le(f),0,m);var b=f;return f-=a.length,f>=0&&o.slice(f,b)==a}function xM(o){return o=_e(o),o&&i1.test(o)?o.replace(zp,hE):o}function EM(o){return o=_e(o),o&&u1.test(o)?o.replace(sc,"\\$&"):o}var TM=fi(function(o,a,f){return o+(f?"-":"")+a.toLowerCase()}),OM=fi(function(o,a,f){return o+(f?" ":"")+a.toLowerCase()}),AM=fg("toLowerCase");function CM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;if(!a||m>=a)return o;var b=(a-m)/2;return Ho(Mo(b),f)+o+Ho(Co(b),f)}function MM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;return a&&m<a?o+Ho(a-m,f):o}function NM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;return a&&m<a?Ho(a-m,f)+o:o}function IM(o,a,f){return f||a==null?a=0:a&&(a=+a),zE(_e(o).replace(oc,""),a||0)}function PM(o,a,f){return(f?ht(o,a,f):a===t)?a=1:a=le(a),Fc(_e(o),a)}function RM(){var o=arguments,a=_e(o[0]);return o.length<3?a:a.replace(o[1],o[2])}var DM=fi(function(o,a,f){return o+(f?"_":"")+a.toLowerCase()});function LM(o,a,f){return f&&typeof f!="number"&&ht(o,a,f)&&(a=f=t),f=f===t?te:f>>>0,f?(o=_e(o),o&&(typeof a=="string"||a!=null&&!lu(a))&&(a=Ot(a),!a&&ri(o))?rr(Xt(o),0,f):o.split(a,f)):[]}var BM=fi(function(o,a,f){return o+(f?" ":"")+uu(a)});function FM(o,a,f){return o=_e(o),f=f==null?0:Ar(le(f),0,o.length),a=Ot(a),o.slice(f,f+a.length)==a}function zM(o,a,f){var m=v.templateSettings;f&&ht(o,a,f)&&(a=t),o=_e(o),a=tl({},a,m,_g);var b=tl({},a.imports,m.imports,_g),w=qe(b),x=wc(b,w),E,O,N=0,I=a.interpolate||po,R="__p += '",$=kc((a.escape||po).source+"|"+I.source+"|"+(I===Wp?_1:po).source+"|"+(a.evaluate||po).source+"|$","g"),G="//# sourceURL="+(be.call(a,"sourceURL")?(a.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++J1+"]")+`
112
+ `)}function fO(o){return se(o)||Pr(o)||!!(Am&&o&&o[Am])}function An(o,a){var f=typeof o;return a=a??wn,!!a&&(f=="number"||f!="symbol"&&k1.test(o))&&o>-1&&o%1==0&&o<a}function ht(o,a,f){if(!Ae(f))return!1;var m=typeof a;return(m=="number"?vt(f)&&An(a,f.length):m=="string"&&a in f)?en(f[a],o):!1}function Xc(o,a){if(se(o))return!1;var f=typeof o;return f=="number"||f=="symbol"||f=="boolean"||o==null||At(o)?!0:a1.test(o)||!l1.test(o)||a!=null&&o in Se(a)}function dO(o){var a=typeof o;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?o!=="__proto__":o===null}function Zc(o){var a=Ko(o),f=v[a];if(typeof f!="function"||!(a in he.prototype))return!1;if(o===f)return!0;var m=Gc(f);return!!m&&o===m[0]}function hO(o){return!!xm&&xm in o}var pO=wo?Cn:gu;function us(o){var a=o&&o.constructor,f=typeof a=="function"&&a.prototype||oi;return o===f}function xg(o){return o===o&&!Ae(o)}function Eg(o,a){return function(f){return f==null?!1:f[o]===a&&(a!==t||o in Se(f))}}function mO(o){var a=Qo(o,function(m){return f.size===d&&f.clear(),m}),f=a.cache;return a}function gO(o,a){var f=o[1],m=a[1],b=f|m,w=b<(k|A|J),x=m==J&&f==L||m==J&&f==j&&o[7].length<=a[8]||m==(J|j)&&a[7].length<=a[8]&&f==L;if(!(w||x))return o;m&k&&(o[2]=a[2],b|=f&k?0:P);var E=a[3];if(E){var O=o[3];o[3]=O?lg(O,E,a[4]):E,o[4]=O?Xn(o[3],h):a[4]}return E=a[5],E&&(O=o[5],o[5]=O?ag(O,E,a[6]):E,o[6]=O?Xn(o[5],h):a[6]),E=a[7],E&&(o[7]=E),m&J&&(o[8]=o[8]==null?a[8]:st(o[8],a[8])),o[9]==null&&(o[9]=a[9]),o[0]=a[0],o[1]=b,o}function yO(o){var a=[];if(o!=null)for(var f in Se(o))a.push(f);return a}function _O(o){return ko.call(o)}function Tg(o,a,f){return a=We(a===t?o.length-1:a,0),function(){for(var m=arguments,b=-1,w=We(m.length-a,0),x=C(w);++b<w;)x[b]=m[a+b];b=-1;for(var E=C(a+1);++b<a;)E[b]=m[b];return E[a]=f(x),Et(o,this,E)}}function Og(o,a){return a.length<2?o:Mr(o,Ut(a,0,-1))}function bO(o,a){for(var f=o.length,m=st(a.length,f),b=bt(o);m--;){var w=a[m];o[m]=An(w,f)?b[w]:t}return o}function eu(o,a){if(!(a==="constructor"&&typeof o[a]=="function")&&a!="__proto__")return o[a]}var Ag=Mg(Qm),fs=RE||function(o,a){return Ze.setTimeout(o,a)},tu=Mg(VT);function Cg(o,a,f){var m=a+"";return tu(o,uO(m,vO(lO(m),f)))}function Mg(o){var a=0,f=0;return function(){var m=FE(),b=_t-(m-f);if(f=m,b>0){if(++a>=Le)return arguments[0]}else a=0;return o.apply(t,arguments)}}function qo(o,a){var f=-1,m=o.length,b=m-1;for(a=a===t?m:a;++f<a;){var w=Bc(f,b),x=o[w];o[w]=o[f],o[f]=x}return o.length=a,o}var Ng=mO(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(c1,function(f,m,b,w){a.push(b?w.replace(y1,"$1"):m||f)}),a});function dn(o){if(typeof o=="string"||At(o))return o;var a=o+"";return a=="0"&&1/o==-1/0?"-0":a}function Ir(o){if(o!=null){try{return So.call(o)}catch{}try{return o+""}catch{}}return""}function vO(o,a){return Wt(cn,function(f){var m="_."+f[0];a&f[1]&&!yo(o,m)&&o.push(m)}),o.sort()}function Ig(o){if(o instanceof he)return o.clone();var a=new Vt(o.__wrapped__,o.__chain__);return a.__actions__=bt(o.__actions__),a.__index__=o.__index__,a.__values__=o.__values__,a}function wO(o,a,f){(f?ht(o,a,f):a===t)?a=1:a=We(le(a),0);var m=o==null?0:o.length;if(!m||a<1)return[];for(var b=0,w=0,x=C(Co(m/a));b<m;)x[w++]=Ut(o,b,b+=a);return x}function SO(o){for(var a=-1,f=o==null?0:o.length,m=0,b=[];++a<f;){var w=o[a];w&&(b[m++]=w)}return b}function kO(){var o=arguments.length;if(!o)return[];for(var a=C(o-1),f=arguments[0],m=o;m--;)a[m-1]=arguments[m];return Qn(se(f)?bt(f):[f],et(a,1))}var xO=fe(function(o,a){return Pe(o)?is(o,et(a,1,Pe,!0)):[]}),EO=fe(function(o,a){var f=Kt(a);return Pe(f)&&(f=t),Pe(o)?is(o,et(a,1,Pe,!0),X(f,2)):[]}),TO=fe(function(o,a){var f=Kt(a);return Pe(f)&&(f=t),Pe(o)?is(o,et(a,1,Pe,!0),t,f):[]});function OO(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),Ut(o,a<0?0:a,m)):[]}function AO(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),a=m-a,Ut(o,0,a<0?0:a)):[]}function CO(o,a){return o&&o.length?zo(o,X(a,3),!0,!0):[]}function MO(o,a){return o&&o.length?zo(o,X(a,3),!0):[]}function NO(o,a,f,m){var b=o==null?0:o.length;return b?(f&&typeof f!="number"&&ht(o,a,f)&&(f=0,m=b),kT(o,a,f,m)):[]}function Pg(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:le(f);return b<0&&(b=We(m+b,0)),_o(o,X(a,3),b)}function Rg(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=m-1;return f!==t&&(b=le(f),b=f<0?We(m+b,0):st(b,m-1)),_o(o,X(a,3),b,!0)}function Dg(o){var a=o==null?0:o.length;return a?et(o,1):[]}function IO(o){var a=o==null?0:o.length;return a?et(o,Gt):[]}function PO(o,a){var f=o==null?0:o.length;return f?(a=a===t?1:le(a),et(o,a)):[]}function RO(o){for(var a=-1,f=o==null?0:o.length,m={};++a<f;){var b=o[a];m[b[0]]=b[1]}return m}function Lg(o){return o&&o.length?o[0]:t}function DO(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:le(f);return b<0&&(b=We(m+b,0)),ni(o,a,b)}function LO(o){var a=o==null?0:o.length;return a?Ut(o,0,-1):[]}var BO=fe(function(o){var a=Oe(o,Vc);return a.length&&a[0]===o[0]?Ic(a):[]}),FO=fe(function(o){var a=Kt(o),f=Oe(o,Vc);return a===Kt(f)?a=t:f.pop(),f.length&&f[0]===o[0]?Ic(f,X(a,2)):[]}),zO=fe(function(o){var a=Kt(o),f=Oe(o,Vc);return a=typeof a=="function"?a:t,a&&f.pop(),f.length&&f[0]===o[0]?Ic(f,t,a):[]});function WO(o,a){return o==null?"":LE.call(o,a)}function Kt(o){var a=o==null?0:o.length;return a?o[a-1]:t}function $O(o,a,f){var m=o==null?0:o.length;if(!m)return-1;var b=m;return f!==t&&(b=le(f),b=b<0?We(m+b,0):st(b,m-1)),a===a?vE(o,a,b):_o(o,gm,b,!0)}function VO(o,a){return o&&o.length?qm(o,le(a)):t}var HO=fe(Bg);function Bg(o,a){return o&&o.length&&a&&a.length?Lc(o,a):o}function UO(o,a,f){return o&&o.length&&a&&a.length?Lc(o,a,X(f,2)):o}function KO(o,a,f){return o&&o.length&&a&&a.length?Lc(o,a,t,f):o}var jO=On(function(o,a){var f=o==null?0:o.length,m=Ac(o,a);return Ym(o,Oe(a,function(b){return An(b,f)?+b:b}).sort(og)),m});function qO(o,a){var f=[];if(!(o&&o.length))return f;var m=-1,b=[],w=o.length;for(a=X(a,3);++m<w;){var x=o[m];a(x,m,o)&&(f.push(x),b.push(m))}return Ym(o,b),f}function nu(o){return o==null?o:WE.call(o)}function JO(o,a,f){var m=o==null?0:o.length;return m?(f&&typeof f!="number"&&ht(o,a,f)?(a=0,f=m):(a=a==null?0:le(a),f=f===t?m:le(f)),Ut(o,a,f)):[]}function GO(o,a){return Fo(o,a)}function YO(o,a,f){return zc(o,a,X(f,2))}function QO(o,a){var f=o==null?0:o.length;if(f){var m=Fo(o,a);if(m<f&&en(o[m],a))return m}return-1}function XO(o,a){return Fo(o,a,!0)}function ZO(o,a,f){return zc(o,a,X(f,2),!0)}function eA(o,a){var f=o==null?0:o.length;if(f){var m=Fo(o,a,!0)-1;if(en(o[m],a))return m}return-1}function tA(o){return o&&o.length?Xm(o):[]}function nA(o,a){return o&&o.length?Xm(o,X(a,2)):[]}function rA(o){var a=o==null?0:o.length;return a?Ut(o,1,a):[]}function iA(o,a,f){return o&&o.length?(a=f||a===t?1:le(a),Ut(o,0,a<0?0:a)):[]}function sA(o,a,f){var m=o==null?0:o.length;return m?(a=f||a===t?1:le(a),a=m-a,Ut(o,a<0?0:a,m)):[]}function oA(o,a){return o&&o.length?zo(o,X(a,3),!1,!0):[]}function lA(o,a){return o&&o.length?zo(o,X(a,3)):[]}var aA=fe(function(o){return tr(et(o,1,Pe,!0))}),cA=fe(function(o){var a=Kt(o);return Pe(a)&&(a=t),tr(et(o,1,Pe,!0),X(a,2))}),uA=fe(function(o){var a=Kt(o);return a=typeof a=="function"?a:t,tr(et(o,1,Pe,!0),t,a)});function fA(o){return o&&o.length?tr(o):[]}function dA(o,a){return o&&o.length?tr(o,X(a,2)):[]}function hA(o,a){return a=typeof a=="function"?a:t,o&&o.length?tr(o,t,a):[]}function ru(o){if(!(o&&o.length))return[];var a=0;return o=Yn(o,function(f){if(Pe(f))return a=We(f.length,a),!0}),vc(a,function(f){return Oe(o,yc(f))})}function Fg(o,a){if(!(o&&o.length))return[];var f=ru(o);return a==null?f:Oe(f,function(m){return Et(a,t,m)})}var pA=fe(function(o,a){return Pe(o)?is(o,a):[]}),mA=fe(function(o){return $c(Yn(o,Pe))}),gA=fe(function(o){var a=Kt(o);return Pe(a)&&(a=t),$c(Yn(o,Pe),X(a,2))}),yA=fe(function(o){var a=Kt(o);return a=typeof a=="function"?a:t,$c(Yn(o,Pe),t,a)}),_A=fe(ru);function bA(o,a){return ng(o||[],a||[],rs)}function vA(o,a){return ng(o||[],a||[],as)}var wA=fe(function(o){var a=o.length,f=a>1?o[a-1]:t;return f=typeof f=="function"?(o.pop(),f):t,Fg(o,f)});function zg(o){var a=v(o);return a.__chain__=!0,a}function SA(o,a){return a(o),o}function Jo(o,a){return a(o)}var kA=On(function(o){var a=o.length,f=a?o[0]:0,m=this.__wrapped__,b=function(w){return Ac(w,o)};return a>1||this.__actions__.length||!(m instanceof he)||!An(f)?this.thru(b):(m=m.slice(f,+f+(a?1:0)),m.__actions__.push({func:Jo,args:[b],thisArg:t}),new Vt(m,this.__chain__).thru(function(w){return a&&!w.length&&w.push(t),w}))});function xA(){return zg(this)}function EA(){return new Vt(this.value(),this.__chain__)}function TA(){this.__values__===t&&(this.__values__=Zg(this.value()));var o=this.__index__>=this.__values__.length,a=o?t:this.__values__[this.__index__++];return{done:o,value:a}}function OA(){return this}function AA(o){for(var a,f=this;f instanceof Po;){var m=Ig(f);m.__index__=0,m.__values__=t,a?b.__wrapped__=m:a=m;var b=m;f=f.__wrapped__}return b.__wrapped__=o,a}function CA(){var o=this.__wrapped__;if(o instanceof he){var a=o;return this.__actions__.length&&(a=new he(this)),a=a.reverse(),a.__actions__.push({func:Jo,args:[nu],thisArg:t}),new Vt(a,this.__chain__)}return this.thru(nu)}function MA(){return tg(this.__wrapped__,this.__actions__)}var NA=Wo(function(o,a,f){be.call(o,f)?++o[f]:En(o,f,1)});function IA(o,a,f){var m=se(o)?pm:ST;return f&&ht(o,a,f)&&(a=t),m(o,X(a,3))}function PA(o,a){var f=se(o)?Yn:Fm;return f(o,X(a,3))}var RA=dg(Pg),DA=dg(Rg);function LA(o,a){return et(Go(o,a),1)}function BA(o,a){return et(Go(o,a),Gt)}function FA(o,a,f){return f=f===t?1:le(f),et(Go(o,a),f)}function Wg(o,a){var f=se(o)?Wt:er;return f(o,X(a,3))}function $g(o,a){var f=se(o)?rE:Bm;return f(o,X(a,3))}var zA=Wo(function(o,a,f){be.call(o,f)?o[f].push(a):En(o,f,[a])});function WA(o,a,f,m){o=vt(o)?o:pi(o),f=f&&!m?le(f):0;var b=o.length;return f<0&&(f=We(b+f,0)),el(o)?f<=b&&o.indexOf(a,f)>-1:!!b&&ni(o,a,f)>-1}var $A=fe(function(o,a,f){var m=-1,b=typeof a=="function",w=vt(o)?C(o.length):[];return er(o,function(x){w[++m]=b?Et(a,x,f):ss(x,a,f)}),w}),VA=Wo(function(o,a,f){En(o,f,a)});function Go(o,a){var f=se(o)?Oe:Um;return f(o,X(a,3))}function HA(o,a,f,m){return o==null?[]:(se(a)||(a=a==null?[]:[a]),f=m?t:f,se(f)||(f=f==null?[]:[f]),Jm(o,a,f))}var UA=Wo(function(o,a,f){o[f?0:1].push(a)},function(){return[[],[]]});function KA(o,a,f){var m=se(o)?mc:_m,b=arguments.length<3;return m(o,X(a,4),f,b,er)}function jA(o,a,f){var m=se(o)?iE:_m,b=arguments.length<3;return m(o,X(a,4),f,b,Bm)}function qA(o,a){var f=se(o)?Yn:Fm;return f(o,Xo(X(a,3)))}function JA(o){var a=se(o)?Pm:WT;return a(o)}function GA(o,a,f){(f?ht(o,a,f):a===t)?a=1:a=le(a);var m=se(o)?yT:$T;return m(o,a)}function YA(o){var a=se(o)?_T:HT;return a(o)}function QA(o){if(o==null)return 0;if(vt(o))return el(o)?ii(o):o.length;var a=ot(o);return a==Yt||a==Qt?o.size:Rc(o).length}function XA(o,a,f){var m=se(o)?gc:UT;return f&&ht(o,a,f)&&(a=t),m(o,X(a,3))}var ZA=fe(function(o,a){if(o==null)return[];var f=a.length;return f>1&&ht(o,a[0],a[1])?a=[]:f>2&&ht(a[0],a[1],a[2])&&(a=[a[0]]),Jm(o,et(a,1),[])}),Yo=PE||function(){return Ze.Date.now()};function eC(o,a){if(typeof a!="function")throw new $t(l);return o=le(o),function(){if(--o<1)return a.apply(this,arguments)}}function Vg(o,a,f){return a=f?t:a,a=o&&a==null?o.length:a,Tn(o,J,t,t,t,t,a)}function Hg(o,a){var f;if(typeof a!="function")throw new $t(l);return o=le(o),function(){return--o>0&&(f=a.apply(this,arguments)),o<=1&&(a=t),f}}var iu=fe(function(o,a,f){var m=k;if(f.length){var b=Xn(f,di(iu));m|=W}return Tn(o,m,a,f,b)}),Ug=fe(function(o,a,f){var m=k|A;if(f.length){var b=Xn(f,di(Ug));m|=W}return Tn(a,m,o,f,b)});function Kg(o,a,f){a=f?t:a;var m=Tn(o,L,t,t,t,t,t,a);return m.placeholder=Kg.placeholder,m}function jg(o,a,f){a=f?t:a;var m=Tn(o,B,t,t,t,t,t,a);return m.placeholder=jg.placeholder,m}function qg(o,a,f){var m,b,w,x,E,O,N=0,I=!1,R=!1,$=!0;if(typeof o!="function")throw new $t(l);a=jt(a)||0,Ae(f)&&(I=!!f.leading,R="maxWait"in f,w=R?We(jt(f.maxWait)||0,a):w,$="trailing"in f?!!f.trailing:$);function G(Re){var tn=m,Nn=b;return m=b=t,N=Re,x=o.apply(Nn,tn),x}function Z(Re){return N=Re,E=fs(de,a),I?G(Re):x}function ce(Re){var tn=Re-O,Nn=Re-N,dy=a-tn;return R?st(dy,w-Nn):dy}function ee(Re){var tn=Re-O,Nn=Re-N;return O===t||tn>=a||tn<0||R&&Nn>=w}function de(){var Re=Yo();if(ee(Re))return pe(Re);E=fs(de,ce(Re))}function pe(Re){return E=t,$&&m?G(Re):(m=b=t,x)}function Ct(){E!==t&&rg(E),N=0,m=O=b=E=t}function pt(){return E===t?x:pe(Yo())}function Mt(){var Re=Yo(),tn=ee(Re);if(m=arguments,b=this,O=Re,tn){if(E===t)return Z(O);if(R)return rg(E),E=fs(de,a),G(O)}return E===t&&(E=fs(de,a)),x}return Mt.cancel=Ct,Mt.flush=pt,Mt}var tC=fe(function(o,a){return Lm(o,1,a)}),nC=fe(function(o,a,f){return Lm(o,jt(a)||0,f)});function rC(o){return Tn(o,V)}function Qo(o,a){if(typeof o!="function"||a!=null&&typeof a!="function")throw new $t(l);var f=function(){var m=arguments,b=a?a.apply(this,m):m[0],w=f.cache;if(w.has(b))return w.get(b);var x=o.apply(this,m);return f.cache=w.set(b,x)||w,x};return f.cache=new(Qo.Cache||xn),f}Qo.Cache=xn;function Xo(o){if(typeof o!="function")throw new $t(l);return function(){var a=arguments;switch(a.length){case 0:return!o.call(this);case 1:return!o.call(this,a[0]);case 2:return!o.call(this,a[0],a[1]);case 3:return!o.call(this,a[0],a[1],a[2])}return!o.apply(this,a)}}function iC(o){return Hg(2,o)}var sC=KT(function(o,a){a=a.length==1&&se(a[0])?Oe(a[0],Tt(X())):Oe(et(a,1),Tt(X()));var f=a.length;return fe(function(m){for(var b=-1,w=st(m.length,f);++b<w;)m[b]=a[b].call(this,m[b]);return Et(o,this,m)})}),su=fe(function(o,a){var f=Xn(a,di(su));return Tn(o,W,t,a,f)}),Jg=fe(function(o,a){var f=Xn(a,di(Jg));return Tn(o,z,t,a,f)}),oC=On(function(o,a){return Tn(o,j,t,t,t,a)});function lC(o,a){if(typeof o!="function")throw new $t(l);return a=a===t?a:le(a),fe(o,a)}function aC(o,a){if(typeof o!="function")throw new $t(l);return a=a==null?0:We(le(a),0),fe(function(f){var m=f[a],b=rr(f,0,a);return m&&Qn(b,m),Et(o,this,b)})}function cC(o,a,f){var m=!0,b=!0;if(typeof o!="function")throw new $t(l);return Ae(f)&&(m="leading"in f?!!f.leading:m,b="trailing"in f?!!f.trailing:b),qg(o,a,{leading:m,maxWait:a,trailing:b})}function uC(o){return Vg(o,1)}function fC(o,a){return su(Hc(a),o)}function dC(){if(!arguments.length)return[];var o=arguments[0];return se(o)?o:[o]}function hC(o){return Ht(o,g)}function pC(o,a){return a=typeof a=="function"?a:t,Ht(o,g,a)}function mC(o){return Ht(o,p|g)}function gC(o,a){return a=typeof a=="function"?a:t,Ht(o,p|g,a)}function yC(o,a){return a==null||Dm(o,a,qe(a))}function en(o,a){return o===a||o!==o&&a!==a}var _C=Uo(Nc),bC=Uo(function(o,a){return o>=a}),Pr=$m(function(){return arguments}())?$m:function(o){return Ie(o)&&be.call(o,"callee")&&!Om.call(o,"callee")},se=C.isArray,vC=am?Tt(am):AT;function vt(o){return o!=null&&Zo(o.length)&&!Cn(o)}function Pe(o){return Ie(o)&&vt(o)}function wC(o){return o===!0||o===!1||Ie(o)&&dt(o)==Ne}var ir=DE||gu,SC=cm?Tt(cm):CT;function kC(o){return Ie(o)&&o.nodeType===1&&!ds(o)}function xC(o){if(o==null)return!0;if(vt(o)&&(se(o)||typeof o=="string"||typeof o.splice=="function"||ir(o)||hi(o)||Pr(o)))return!o.length;var a=ot(o);if(a==Yt||a==Qt)return!o.size;if(us(o))return!Rc(o).length;for(var f in o)if(be.call(o,f))return!1;return!0}function EC(o,a){return ls(o,a)}function TC(o,a,f){f=typeof f=="function"?f:t;var m=f?f(o,a):t;return m===t?ls(o,a,t,f):!!m}function ou(o){if(!Ie(o))return!1;var a=dt(o);return a==Zr||a==Ki||typeof o.message=="string"&&typeof o.name=="string"&&!ds(o)}function OC(o){return typeof o=="number"&&Cm(o)}function Cn(o){if(!Ae(o))return!1;var a=dt(o);return a==fo||a==Lp||a==Ui||a==Qx}function Gg(o){return typeof o=="number"&&o==le(o)}function Zo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=wn}function Ae(o){var a=typeof o;return o!=null&&(a=="object"||a=="function")}function Ie(o){return o!=null&&typeof o=="object"}var Yg=um?Tt(um):NT;function AC(o,a){return o===a||Pc(o,a,Yc(a))}function CC(o,a,f){return f=typeof f=="function"?f:t,Pc(o,a,Yc(a),f)}function MC(o){return Qg(o)&&o!=+o}function NC(o){if(pO(o))throw new ie(s);return Vm(o)}function IC(o){return o===null}function PC(o){return o==null}function Qg(o){return typeof o=="number"||Ie(o)&&dt(o)==ji}function ds(o){if(!Ie(o)||dt(o)!=Sn)return!1;var a=To(o);if(a===null)return!0;var f=be.call(a,"constructor")&&a.constructor;return typeof f=="function"&&f instanceof f&&So.call(f)==CE}var lu=fm?Tt(fm):IT;function RC(o){return Gg(o)&&o>=-9007199254740991&&o<=wn}var Xg=dm?Tt(dm):PT;function el(o){return typeof o=="string"||!se(o)&&Ie(o)&&dt(o)==Ji}function At(o){return typeof o=="symbol"||Ie(o)&&dt(o)==ho}var hi=hm?Tt(hm):RT;function DC(o){return o===t}function LC(o){return Ie(o)&&ot(o)==Gi}function BC(o){return Ie(o)&&dt(o)==Zx}var FC=Uo(Dc),zC=Uo(function(o,a){return o<=a});function Zg(o){if(!o)return[];if(vt(o))return el(o)?Xt(o):bt(o);if(Xi&&o[Xi])return yE(o[Xi]());var a=ot(o),f=a==Yt?Sc:a==Qt?bo:pi;return f(o)}function Mn(o){if(!o)return o===0?o:0;if(o=jt(o),o===Gt||o===-1/0){var a=o<0?-1:1;return a*uo}return o===o?o:0}function le(o){var a=Mn(o),f=a%1;return a===a?f?a-f:a:0}function ey(o){return o?Cr(le(o),0,te):0}function jt(o){if(typeof o=="number")return o;if(At(o))return F;if(Ae(o)){var a=typeof o.valueOf=="function"?o.valueOf():o;o=Ae(a)?a+"":a}if(typeof o!="string")return o===0?o:+o;o=bm(o);var f=v1.test(o);return f||S1.test(o)?eE(o.slice(2),f?2:8):b1.test(o)?F:+o}function ty(o){return fn(o,wt(o))}function WC(o){return o?Cr(le(o),-9007199254740991,wn):o===0?o:0}function _e(o){return o==null?"":Ot(o)}var $C=ui(function(o,a){if(us(a)||vt(a)){fn(a,qe(a),o);return}for(var f in a)be.call(a,f)&&rs(o,f,a[f])}),ny=ui(function(o,a){fn(a,wt(a),o)}),tl=ui(function(o,a,f,m){fn(a,wt(a),o,m)}),VC=ui(function(o,a,f,m){fn(a,qe(a),o,m)}),HC=On(Ac);function UC(o,a){var f=ci(o);return a==null?f:Rm(f,a)}var KC=fe(function(o,a){o=Se(o);var f=-1,m=a.length,b=m>2?a[2]:t;for(b&&ht(a[0],a[1],b)&&(m=1);++f<m;)for(var w=a[f],x=wt(w),E=-1,O=x.length;++E<O;){var N=x[E],I=o[N];(I===t||en(I,oi[N])&&!be.call(o,N))&&(o[N]=w[N])}return o}),jC=fe(function(o){return o.push(t,bg),Et(ry,t,o)});function qC(o,a){return mm(o,X(a,3),un)}function JC(o,a){return mm(o,X(a,3),Mc)}function GC(o,a){return o==null?o:Cc(o,X(a,3),wt)}function YC(o,a){return o==null?o:zm(o,X(a,3),wt)}function QC(o,a){return o&&un(o,X(a,3))}function XC(o,a){return o&&Mc(o,X(a,3))}function ZC(o){return o==null?[]:Lo(o,qe(o))}function eM(o){return o==null?[]:Lo(o,wt(o))}function au(o,a,f){var m=o==null?t:Mr(o,a);return m===t?f:m}function tM(o,a){return o!=null&&Sg(o,a,xT)}function cu(o,a){return o!=null&&Sg(o,a,ET)}var nM=pg(function(o,a,f){a!=null&&typeof a.toString!="function"&&(a=ko.call(a)),o[a]=f},fu(St)),rM=pg(function(o,a,f){a!=null&&typeof a.toString!="function"&&(a=ko.call(a)),be.call(o,a)?o[a].push(f):o[a]=[f]},X),iM=fe(ss);function qe(o){return vt(o)?Im(o):Rc(o)}function wt(o){return vt(o)?Im(o,!0):DT(o)}function sM(o,a){var f={};return a=X(a,3),un(o,function(m,b,w){En(f,a(m,b,w),m)}),f}function oM(o,a){var f={};return a=X(a,3),un(o,function(m,b,w){En(f,b,a(m,b,w))}),f}var lM=ui(function(o,a,f){Bo(o,a,f)}),ry=ui(function(o,a,f,m){Bo(o,a,f,m)}),aM=On(function(o,a){var f={};if(o==null)return f;var m=!1;a=Oe(a,function(w){return w=nr(w,o),m||(m=w.length>1),w}),fn(o,Jc(o),f),m&&(f=Ht(f,p|y|g,nO));for(var b=a.length;b--;)Wc(f,a[b]);return f});function cM(o,a){return iy(o,Xo(X(a)))}var uM=On(function(o,a){return o==null?{}:BT(o,a)});function iy(o,a){if(o==null)return{};var f=Oe(Jc(o),function(m){return[m]});return a=X(a),Gm(o,f,function(m,b){return a(m,b[0])})}function fM(o,a,f){a=nr(a,o);var m=-1,b=a.length;for(b||(b=1,o=t);++m<b;){var w=o==null?t:o[dn(a[m])];w===t&&(m=b,w=f),o=Cn(w)?w.call(o):w}return o}function dM(o,a,f){return o==null?o:as(o,a,f)}function hM(o,a,f,m){return m=typeof m=="function"?m:t,o==null?o:as(o,a,f,m)}var sy=yg(qe),oy=yg(wt);function pM(o,a,f){var m=se(o),b=m||ir(o)||hi(o);if(a=X(a,4),f==null){var w=o&&o.constructor;b?f=m?new w:[]:Ae(o)?f=Cn(w)?ci(To(o)):{}:f={}}return(b?Wt:un)(o,function(x,E,O){return a(f,x,E,O)}),f}function mM(o,a){return o==null?!0:Wc(o,a)}function gM(o,a,f){return o==null?o:eg(o,a,Hc(f))}function yM(o,a,f,m){return m=typeof m=="function"?m:t,o==null?o:eg(o,a,Hc(f),m)}function pi(o){return o==null?[]:wc(o,qe(o))}function _M(o){return o==null?[]:wc(o,wt(o))}function bM(o,a,f){return f===t&&(f=a,a=t),f!==t&&(f=jt(f),f=f===f?f:0),a!==t&&(a=jt(a),a=a===a?a:0),Cr(jt(o),a,f)}function vM(o,a,f){return a=Mn(a),f===t?(f=a,a=0):f=Mn(f),o=jt(o),TT(o,a,f)}function wM(o,a,f){if(f&&typeof f!="boolean"&&ht(o,a,f)&&(a=f=t),f===t&&(typeof a=="boolean"?(f=a,a=t):typeof o=="boolean"&&(f=o,o=t)),o===t&&a===t?(o=0,a=1):(o=Mn(o),a===t?(a=o,o=0):a=Mn(a)),o>a){var m=o;o=a,a=m}if(f||o%1||a%1){var b=Mm();return st(o+b*(a-o+Z1("1e-"+((b+"").length-1))),a)}return Bc(o,a)}var SM=fi(function(o,a,f){return a=a.toLowerCase(),o+(f?ly(a):a)});function ly(o){return uu(_e(o).toLowerCase())}function ay(o){return o=_e(o),o&&o.replace(x1,dE).replace(H1,"")}function kM(o,a,f){o=_e(o),a=Ot(a);var m=o.length;f=f===t?m:Cr(le(f),0,m);var b=f;return f-=a.length,f>=0&&o.slice(f,b)==a}function xM(o){return o=_e(o),o&&i1.test(o)?o.replace(zp,hE):o}function EM(o){return o=_e(o),o&&u1.test(o)?o.replace(sc,"\\$&"):o}var TM=fi(function(o,a,f){return o+(f?"-":"")+a.toLowerCase()}),OM=fi(function(o,a,f){return o+(f?" ":"")+a.toLowerCase()}),AM=fg("toLowerCase");function CM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;if(!a||m>=a)return o;var b=(a-m)/2;return Ho(Mo(b),f)+o+Ho(Co(b),f)}function MM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;return a&&m<a?o+Ho(a-m,f):o}function NM(o,a,f){o=_e(o),a=le(a);var m=a?ii(o):0;return a&&m<a?Ho(a-m,f)+o:o}function IM(o,a,f){return f||a==null?a=0:a&&(a=+a),zE(_e(o).replace(oc,""),a||0)}function PM(o,a,f){return(f?ht(o,a,f):a===t)?a=1:a=le(a),Fc(_e(o),a)}function RM(){var o=arguments,a=_e(o[0]);return o.length<3?a:a.replace(o[1],o[2])}var DM=fi(function(o,a,f){return o+(f?"_":"")+a.toLowerCase()});function LM(o,a,f){return f&&typeof f!="number"&&ht(o,a,f)&&(a=f=t),f=f===t?te:f>>>0,f?(o=_e(o),o&&(typeof a=="string"||a!=null&&!lu(a))&&(a=Ot(a),!a&&ri(o))?rr(Xt(o),0,f):o.split(a,f)):[]}var BM=fi(function(o,a,f){return o+(f?" ":"")+uu(a)});function FM(o,a,f){return o=_e(o),f=f==null?0:Cr(le(f),0,o.length),a=Ot(a),o.slice(f,f+a.length)==a}function zM(o,a,f){var m=v.templateSettings;f&&ht(o,a,f)&&(a=t),o=_e(o),a=tl({},a,m,_g);var b=tl({},a.imports,m.imports,_g),w=qe(b),x=wc(b,w),E,O,N=0,I=a.interpolate||po,R="__p += '",$=kc((a.escape||po).source+"|"+I.source+"|"+(I===Wp?_1:po).source+"|"+(a.evaluate||po).source+"|$","g"),G="//# sourceURL="+(be.call(a,"sourceURL")?(a.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++J1+"]")+`
111
113
  `;o.replace($,function(ee,de,pe,Ct,pt,Mt){return pe||(pe=Ct),R+=o.slice(N,Mt).replace(E1,pE),de&&(E=!0,R+=`' +
112
114
  __e(`+de+`) +
113
115
  '`),pt&&(O=!0,R+=`';
@@ -124,7 +126,7 @@ __p += '`),pe&&(R+=`' +
124
126
  function print() { __p += __j.call(arguments, '') }
125
127
  `:`;
126
128
  `)+R+`return __p
127
- }`;var ce=uy(function(){return ye(w,G+"return "+R).apply(t,x)});if(ce.source=R,ou(ce))throw ce;return ce}function WM(o){return _e(o).toLowerCase()}function $M(o){return _e(o).toUpperCase()}function VM(o,a,f){if(o=_e(o),o&&(f||a===t))return bm(o);if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=Xt(a),w=vm(m,b),x=wm(m,b)+1;return rr(m,w,x).join("")}function HM(o,a,f){if(o=_e(o),o&&(f||a===t))return o.slice(0,km(o)+1);if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=wm(m,Xt(a))+1;return rr(m,0,b).join("")}function UM(o,a,f){if(o=_e(o),o&&(f||a===t))return o.replace(oc,"");if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=vm(m,Xt(a));return rr(m,b).join("")}function KM(o,a){var f=ne,m=ve;if(Ae(a)){var b="separator"in a?a.separator:b;f="length"in a?le(a.length):f,m="omission"in a?Ot(a.omission):m}o=_e(o);var w=o.length;if(ri(o)){var x=Xt(o);w=x.length}if(f>=w)return o;var E=f-ii(m);if(E<1)return m;var O=x?rr(x,0,E).join(""):o.slice(0,E);if(b===t)return O+m;if(x&&(E+=O.length-E),lu(b)){if(o.slice(E).search(b)){var N,I=O;for(b.global||(b=kc(b.source,_e($p.exec(b))+"g")),b.lastIndex=0;N=b.exec(I);)var R=N.index;O=O.slice(0,R===t?E:R)}}else if(o.indexOf(Ot(b),E)!=E){var $=O.lastIndexOf(b);$>-1&&(O=O.slice(0,$))}return O+m}function jM(o){return o=_e(o),o&&r1.test(o)?o.replace(Fp,wE):o}var qM=fi(function(o,a,f){return o+(f?" ":"")+a.toUpperCase()}),uu=fg("toUpperCase");function cy(o,a,f){return o=_e(o),a=f?t:a,a===t?gE(o)?xE(o):lE(o):o.match(a)||[]}var uy=fe(function(o,a){try{return Et(o,t,a)}catch(f){return ou(f)?f:new ie(f)}}),JM=On(function(o,a){return Wt(a,function(f){f=dn(f),En(o,f,iu(o[f],o))}),o});function GM(o){var a=o==null?0:o.length,f=X();return o=a?Oe(o,function(m){if(typeof m[1]!="function")throw new $t(l);return[f(m[0]),m[1]]}):[],fe(function(m){for(var b=-1;++b<a;){var w=o[b];if(Et(w[0],this,m))return Et(w[1],this,m)}})}function YM(o){return wT(Ht(o,p))}function fu(o){return function(){return o}}function QM(o,a){return o==null||o!==o?a:o}var XM=hg(),ZM=hg(!0);function St(o){return o}function du(o){return Hm(typeof o=="function"?o:Ht(o,p))}function eN(o){return Km(Ht(o,p))}function tN(o,a){return jm(o,Ht(a,p))}var nN=fe(function(o,a){return function(f){return ss(f,o,a)}}),rN=fe(function(o,a){return function(f){return ss(o,f,a)}});function hu(o,a,f){var m=qe(a),b=Lo(a,m);f==null&&!(Ae(a)&&(b.length||!m.length))&&(f=a,a=o,o=this,b=Lo(a,qe(a)));var w=!(Ae(f)&&"chain"in f)||!!f.chain,x=Cn(o);return Wt(b,function(E){var O=a[E];o[E]=O,x&&(o.prototype[E]=function(){var N=this.__chain__;if(w||N){var I=o(this.__wrapped__),R=I.__actions__=bt(this.__actions__);return R.push({func:O,args:arguments,thisArg:o}),I.__chain__=N,I}return O.apply(o,Qn([this.value()],arguments))})}),o}function iN(){return Ze._===this&&(Ze._=ME),this}function pu(){}function sN(o){return o=le(o),fe(function(a){return qm(a,o)})}var oN=Kc(Oe),lN=Kc(pm),aN=Kc(gc);function fy(o){return Xc(o)?yc(dn(o)):FT(o)}function cN(o){return function(a){return o==null?t:Cr(o,a)}}var uN=mg(),fN=mg(!0);function mu(){return[]}function gu(){return!1}function dN(){return{}}function hN(){return""}function pN(){return!0}function mN(o,a){if(o=le(o),o<1||o>wn)return[];var f=te,m=st(o,te);a=X(a),o-=te;for(var b=vc(m,a);++f<o;)a(f);return b}function gN(o){return se(o)?Oe(o,dn):At(o)?[o]:bt(Ng(_e(o)))}function yN(o){var a=++AE;return _e(o)+a}var _N=Vo(function(o,a){return o+a},0),bN=jc("ceil"),vN=Vo(function(o,a){return o/a},1),wN=jc("floor");function SN(o){return o&&o.length?Do(o,St,Nc):t}function kN(o,a){return o&&o.length?Do(o,X(a,2),Nc):t}function xN(o){return ym(o,St)}function EN(o,a){return ym(o,X(a,2))}function TN(o){return o&&o.length?Do(o,St,Dc):t}function ON(o,a){return o&&o.length?Do(o,X(a,2),Dc):t}var AN=Vo(function(o,a){return o*a},1),CN=jc("round"),MN=Vo(function(o,a){return o-a},0);function NN(o){return o&&o.length?bc(o,St):0}function IN(o,a){return o&&o.length?bc(o,X(a,2)):0}return v.after=eC,v.ary=Vg,v.assign=$C,v.assignIn=ny,v.assignInWith=tl,v.assignWith=VC,v.at=HC,v.before=Hg,v.bind=iu,v.bindAll=JM,v.bindKey=Ug,v.castArray=dC,v.chain=zg,v.chunk=wO,v.compact=SO,v.concat=kO,v.cond=GM,v.conforms=YM,v.constant=fu,v.countBy=NA,v.create=UC,v.curry=Kg,v.curryRight=jg,v.debounce=qg,v.defaults=KC,v.defaultsDeep=jC,v.defer=tC,v.delay=nC,v.difference=xO,v.differenceBy=EO,v.differenceWith=TO,v.drop=OO,v.dropRight=AO,v.dropRightWhile=CO,v.dropWhile=MO,v.fill=NO,v.filter=PA,v.flatMap=LA,v.flatMapDeep=BA,v.flatMapDepth=FA,v.flatten=Dg,v.flattenDeep=IO,v.flattenDepth=PO,v.flip=rC,v.flow=XM,v.flowRight=ZM,v.fromPairs=RO,v.functions=ZC,v.functionsIn=eM,v.groupBy=zA,v.initial=LO,v.intersection=BO,v.intersectionBy=FO,v.intersectionWith=zO,v.invert=nM,v.invertBy=rM,v.invokeMap=$A,v.iteratee=du,v.keyBy=VA,v.keys=qe,v.keysIn=wt,v.map=Go,v.mapKeys=sM,v.mapValues=oM,v.matches=eN,v.matchesProperty=tN,v.memoize=Qo,v.merge=lM,v.mergeWith=ry,v.method=nN,v.methodOf=rN,v.mixin=hu,v.negate=Xo,v.nthArg=sN,v.omit=aM,v.omitBy=cM,v.once=iC,v.orderBy=HA,v.over=oN,v.overArgs=sC,v.overEvery=lN,v.overSome=aN,v.partial=su,v.partialRight=Jg,v.partition=UA,v.pick=uM,v.pickBy=iy,v.property=fy,v.propertyOf=cN,v.pull=HO,v.pullAll=Bg,v.pullAllBy=UO,v.pullAllWith=KO,v.pullAt=jO,v.range=uN,v.rangeRight=fN,v.rearg=oC,v.reject=qA,v.remove=qO,v.rest=lC,v.reverse=nu,v.sampleSize=GA,v.set=dM,v.setWith=hM,v.shuffle=YA,v.slice=JO,v.sortBy=ZA,v.sortedUniq=tA,v.sortedUniqBy=nA,v.split=LM,v.spread=aC,v.tail=rA,v.take=iA,v.takeRight=sA,v.takeRightWhile=oA,v.takeWhile=lA,v.tap=SA,v.throttle=cC,v.thru=Jo,v.toArray=Zg,v.toPairs=sy,v.toPairsIn=oy,v.toPath=gN,v.toPlainObject=ty,v.transform=pM,v.unary=uC,v.union=aA,v.unionBy=cA,v.unionWith=uA,v.uniq=fA,v.uniqBy=dA,v.uniqWith=hA,v.unset=mM,v.unzip=ru,v.unzipWith=Fg,v.update=gM,v.updateWith=yM,v.values=pi,v.valuesIn=_M,v.without=pA,v.words=cy,v.wrap=fC,v.xor=mA,v.xorBy=gA,v.xorWith=yA,v.zip=_A,v.zipObject=bA,v.zipObjectDeep=vA,v.zipWith=wA,v.entries=sy,v.entriesIn=oy,v.extend=ny,v.extendWith=tl,hu(v,v),v.add=_N,v.attempt=uy,v.camelCase=SM,v.capitalize=ly,v.ceil=bN,v.clamp=bM,v.clone=hC,v.cloneDeep=mC,v.cloneDeepWith=gC,v.cloneWith=pC,v.conformsTo=yC,v.deburr=ay,v.defaultTo=QM,v.divide=vN,v.endsWith=kM,v.eq=en,v.escape=xM,v.escapeRegExp=EM,v.every=IA,v.find=RA,v.findIndex=Pg,v.findKey=qC,v.findLast=DA,v.findLastIndex=Rg,v.findLastKey=JC,v.floor=wN,v.forEach=Wg,v.forEachRight=$g,v.forIn=GC,v.forInRight=YC,v.forOwn=QC,v.forOwnRight=XC,v.get=au,v.gt=_C,v.gte=bC,v.has=tM,v.hasIn=cu,v.head=Lg,v.identity=St,v.includes=WA,v.indexOf=DO,v.inRange=vM,v.invoke=iM,v.isArguments=Ir,v.isArray=se,v.isArrayBuffer=vC,v.isArrayLike=vt,v.isArrayLikeObject=Pe,v.isBoolean=wC,v.isBuffer=ir,v.isDate=SC,v.isElement=kC,v.isEmpty=xC,v.isEqual=EC,v.isEqualWith=TC,v.isError=ou,v.isFinite=OC,v.isFunction=Cn,v.isInteger=Gg,v.isLength=Zo,v.isMap=Yg,v.isMatch=AC,v.isMatchWith=CC,v.isNaN=MC,v.isNative=NC,v.isNil=PC,v.isNull=IC,v.isNumber=Qg,v.isObject=Ae,v.isObjectLike=Ie,v.isPlainObject=ds,v.isRegExp=lu,v.isSafeInteger=RC,v.isSet=Xg,v.isString=el,v.isSymbol=At,v.isTypedArray=hi,v.isUndefined=DC,v.isWeakMap=LC,v.isWeakSet=BC,v.join=WO,v.kebabCase=TM,v.last=Kt,v.lastIndexOf=$O,v.lowerCase=OM,v.lowerFirst=AM,v.lt=FC,v.lte=zC,v.max=SN,v.maxBy=kN,v.mean=xN,v.meanBy=EN,v.min=TN,v.minBy=ON,v.stubArray=mu,v.stubFalse=gu,v.stubObject=dN,v.stubString=hN,v.stubTrue=pN,v.multiply=AN,v.nth=VO,v.noConflict=iN,v.noop=pu,v.now=Yo,v.pad=CM,v.padEnd=MM,v.padStart=NM,v.parseInt=IM,v.random=wM,v.reduce=KA,v.reduceRight=jA,v.repeat=PM,v.replace=RM,v.result=fM,v.round=CN,v.runInContext=T,v.sample=JA,v.size=QA,v.snakeCase=DM,v.some=XA,v.sortedIndex=GO,v.sortedIndexBy=YO,v.sortedIndexOf=QO,v.sortedLastIndex=XO,v.sortedLastIndexBy=ZO,v.sortedLastIndexOf=eA,v.startCase=BM,v.startsWith=FM,v.subtract=MN,v.sum=NN,v.sumBy=IN,v.template=zM,v.times=mN,v.toFinite=Mn,v.toInteger=le,v.toLength=ey,v.toLower=WM,v.toNumber=jt,v.toSafeInteger=WC,v.toString=_e,v.toUpper=$M,v.trim=VM,v.trimEnd=HM,v.trimStart=UM,v.truncate=KM,v.unescape=jM,v.uniqueId=yN,v.upperCase=qM,v.upperFirst=uu,v.each=Wg,v.eachRight=$g,v.first=Lg,hu(v,function(){var o={};return un(v,function(a,f){be.call(v.prototype,f)||(o[f]=a)}),o}(),{chain:!1}),v.VERSION=r,Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){v[o].placeholder=v}),Wt(["drop","take"],function(o,a){he.prototype[o]=function(f){f=f===t?1:We(le(f),0);var m=this.__filtered__&&!a?new he(this):this.clone();return m.__filtered__?m.__takeCount__=st(f,m.__takeCount__):m.__views__.push({size:st(f,te),type:o+(m.__dir__<0?"Right":"")}),m},he.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),Wt(["filter","map","takeWhile"],function(o,a){var f=a+1,m=f==Ke||f==ft;he.prototype[o]=function(b){var w=this.clone();return w.__iteratees__.push({iteratee:X(b,3),type:f}),w.__filtered__=w.__filtered__||m,w}}),Wt(["head","last"],function(o,a){var f="take"+(a?"Right":"");he.prototype[o]=function(){return this[f](1).value()[0]}}),Wt(["initial","tail"],function(o,a){var f="drop"+(a?"":"Right");he.prototype[o]=function(){return this.__filtered__?new he(this):this[f](1)}}),he.prototype.compact=function(){return this.filter(St)},he.prototype.find=function(o){return this.filter(o).head()},he.prototype.findLast=function(o){return this.reverse().find(o)},he.prototype.invokeMap=fe(function(o,a){return typeof o=="function"?new he(this):this.map(function(f){return ss(f,o,a)})}),he.prototype.reject=function(o){return this.filter(Xo(X(o)))},he.prototype.slice=function(o,a){o=le(o);var f=this;return f.__filtered__&&(o>0||a<0)?new he(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),a!==t&&(a=le(a),f=a<0?f.dropRight(-a):f.take(a-o)),f)},he.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},he.prototype.toArray=function(){return this.take(te)},un(he.prototype,function(o,a){var f=/^(?:filter|find|map|reject)|While$/.test(a),m=/^(?:head|last)$/.test(a),b=v[m?"take"+(a=="last"?"Right":""):a],w=m||/^find/.test(a);b&&(v.prototype[a]=function(){var x=this.__wrapped__,E=m?[1]:arguments,O=x instanceof he,N=E[0],I=O||se(x),R=function(de){var pe=b.apply(v,Qn([de],E));return m&&$?pe[0]:pe};I&&f&&typeof N=="function"&&N.length!=1&&(O=I=!1);var $=this.__chain__,G=!!this.__actions__.length,Z=w&&!$,ce=O&&!G;if(!w&&I){x=ce?x:new he(this);var ee=o.apply(x,E);return ee.__actions__.push({func:Jo,args:[R],thisArg:t}),new Vt(ee,$)}return Z&&ce?o.apply(this,E):(ee=this.thru(R),Z?m?ee.value()[0]:ee.value():ee)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(o){var a=vo[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",m=/^(?:pop|shift)$/.test(o);v.prototype[o]=function(){var b=arguments;if(m&&!this.__chain__){var w=this.value();return a.apply(se(w)?w:[],b)}return this[f](function(x){return a.apply(se(x)?x:[],b)})}}),un(he.prototype,function(o,a){var f=v[a];if(f){var m=f.name+"";be.call(ai,m)||(ai[m]=[]),ai[m].push({name:a,func:f})}}),ai[$o(t,A).name]=[{name:"wrapper",func:t}],he.prototype.clone=jE,he.prototype.reverse=qE,he.prototype.value=JE,v.prototype.at=kA,v.prototype.chain=xA,v.prototype.commit=EA,v.prototype.next=TA,v.prototype.plant=AA,v.prototype.reverse=CA,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=MA,v.prototype.first=v.prototype.head,Xi&&(v.prototype[Xi]=OA),v},si=EE();xr?((xr.exports=si)._=si,dc._=si):Ze._=si}).call(mi)}(ks,ks.exports);var A_=ks.exports;const C_=Pr.graphql(`
129
+ }`;var ce=uy(function(){return ye(w,G+"return "+R).apply(t,x)});if(ce.source=R,ou(ce))throw ce;return ce}function WM(o){return _e(o).toLowerCase()}function $M(o){return _e(o).toUpperCase()}function VM(o,a,f){if(o=_e(o),o&&(f||a===t))return bm(o);if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=Xt(a),w=vm(m,b),x=wm(m,b)+1;return rr(m,w,x).join("")}function HM(o,a,f){if(o=_e(o),o&&(f||a===t))return o.slice(0,km(o)+1);if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=wm(m,Xt(a))+1;return rr(m,0,b).join("")}function UM(o,a,f){if(o=_e(o),o&&(f||a===t))return o.replace(oc,"");if(!o||!(a=Ot(a)))return o;var m=Xt(o),b=vm(m,Xt(a));return rr(m,b).join("")}function KM(o,a){var f=ne,m=ve;if(Ae(a)){var b="separator"in a?a.separator:b;f="length"in a?le(a.length):f,m="omission"in a?Ot(a.omission):m}o=_e(o);var w=o.length;if(ri(o)){var x=Xt(o);w=x.length}if(f>=w)return o;var E=f-ii(m);if(E<1)return m;var O=x?rr(x,0,E).join(""):o.slice(0,E);if(b===t)return O+m;if(x&&(E+=O.length-E),lu(b)){if(o.slice(E).search(b)){var N,I=O;for(b.global||(b=kc(b.source,_e($p.exec(b))+"g")),b.lastIndex=0;N=b.exec(I);)var R=N.index;O=O.slice(0,R===t?E:R)}}else if(o.indexOf(Ot(b),E)!=E){var $=O.lastIndexOf(b);$>-1&&(O=O.slice(0,$))}return O+m}function jM(o){return o=_e(o),o&&r1.test(o)?o.replace(Fp,wE):o}var qM=fi(function(o,a,f){return o+(f?" ":"")+a.toUpperCase()}),uu=fg("toUpperCase");function cy(o,a,f){return o=_e(o),a=f?t:a,a===t?gE(o)?xE(o):lE(o):o.match(a)||[]}var uy=fe(function(o,a){try{return Et(o,t,a)}catch(f){return ou(f)?f:new ie(f)}}),JM=On(function(o,a){return Wt(a,function(f){f=dn(f),En(o,f,iu(o[f],o))}),o});function GM(o){var a=o==null?0:o.length,f=X();return o=a?Oe(o,function(m){if(typeof m[1]!="function")throw new $t(l);return[f(m[0]),m[1]]}):[],fe(function(m){for(var b=-1;++b<a;){var w=o[b];if(Et(w[0],this,m))return Et(w[1],this,m)}})}function YM(o){return wT(Ht(o,p))}function fu(o){return function(){return o}}function QM(o,a){return o==null||o!==o?a:o}var XM=hg(),ZM=hg(!0);function St(o){return o}function du(o){return Hm(typeof o=="function"?o:Ht(o,p))}function eN(o){return Km(Ht(o,p))}function tN(o,a){return jm(o,Ht(a,p))}var nN=fe(function(o,a){return function(f){return ss(f,o,a)}}),rN=fe(function(o,a){return function(f){return ss(o,f,a)}});function hu(o,a,f){var m=qe(a),b=Lo(a,m);f==null&&!(Ae(a)&&(b.length||!m.length))&&(f=a,a=o,o=this,b=Lo(a,qe(a)));var w=!(Ae(f)&&"chain"in f)||!!f.chain,x=Cn(o);return Wt(b,function(E){var O=a[E];o[E]=O,x&&(o.prototype[E]=function(){var N=this.__chain__;if(w||N){var I=o(this.__wrapped__),R=I.__actions__=bt(this.__actions__);return R.push({func:O,args:arguments,thisArg:o}),I.__chain__=N,I}return O.apply(o,Qn([this.value()],arguments))})}),o}function iN(){return Ze._===this&&(Ze._=ME),this}function pu(){}function sN(o){return o=le(o),fe(function(a){return qm(a,o)})}var oN=Kc(Oe),lN=Kc(pm),aN=Kc(gc);function fy(o){return Xc(o)?yc(dn(o)):FT(o)}function cN(o){return function(a){return o==null?t:Mr(o,a)}}var uN=mg(),fN=mg(!0);function mu(){return[]}function gu(){return!1}function dN(){return{}}function hN(){return""}function pN(){return!0}function mN(o,a){if(o=le(o),o<1||o>wn)return[];var f=te,m=st(o,te);a=X(a),o-=te;for(var b=vc(m,a);++f<o;)a(f);return b}function gN(o){return se(o)?Oe(o,dn):At(o)?[o]:bt(Ng(_e(o)))}function yN(o){var a=++AE;return _e(o)+a}var _N=Vo(function(o,a){return o+a},0),bN=jc("ceil"),vN=Vo(function(o,a){return o/a},1),wN=jc("floor");function SN(o){return o&&o.length?Do(o,St,Nc):t}function kN(o,a){return o&&o.length?Do(o,X(a,2),Nc):t}function xN(o){return ym(o,St)}function EN(o,a){return ym(o,X(a,2))}function TN(o){return o&&o.length?Do(o,St,Dc):t}function ON(o,a){return o&&o.length?Do(o,X(a,2),Dc):t}var AN=Vo(function(o,a){return o*a},1),CN=jc("round"),MN=Vo(function(o,a){return o-a},0);function NN(o){return o&&o.length?bc(o,St):0}function IN(o,a){return o&&o.length?bc(o,X(a,2)):0}return v.after=eC,v.ary=Vg,v.assign=$C,v.assignIn=ny,v.assignInWith=tl,v.assignWith=VC,v.at=HC,v.before=Hg,v.bind=iu,v.bindAll=JM,v.bindKey=Ug,v.castArray=dC,v.chain=zg,v.chunk=wO,v.compact=SO,v.concat=kO,v.cond=GM,v.conforms=YM,v.constant=fu,v.countBy=NA,v.create=UC,v.curry=Kg,v.curryRight=jg,v.debounce=qg,v.defaults=KC,v.defaultsDeep=jC,v.defer=tC,v.delay=nC,v.difference=xO,v.differenceBy=EO,v.differenceWith=TO,v.drop=OO,v.dropRight=AO,v.dropRightWhile=CO,v.dropWhile=MO,v.fill=NO,v.filter=PA,v.flatMap=LA,v.flatMapDeep=BA,v.flatMapDepth=FA,v.flatten=Dg,v.flattenDeep=IO,v.flattenDepth=PO,v.flip=rC,v.flow=XM,v.flowRight=ZM,v.fromPairs=RO,v.functions=ZC,v.functionsIn=eM,v.groupBy=zA,v.initial=LO,v.intersection=BO,v.intersectionBy=FO,v.intersectionWith=zO,v.invert=nM,v.invertBy=rM,v.invokeMap=$A,v.iteratee=du,v.keyBy=VA,v.keys=qe,v.keysIn=wt,v.map=Go,v.mapKeys=sM,v.mapValues=oM,v.matches=eN,v.matchesProperty=tN,v.memoize=Qo,v.merge=lM,v.mergeWith=ry,v.method=nN,v.methodOf=rN,v.mixin=hu,v.negate=Xo,v.nthArg=sN,v.omit=aM,v.omitBy=cM,v.once=iC,v.orderBy=HA,v.over=oN,v.overArgs=sC,v.overEvery=lN,v.overSome=aN,v.partial=su,v.partialRight=Jg,v.partition=UA,v.pick=uM,v.pickBy=iy,v.property=fy,v.propertyOf=cN,v.pull=HO,v.pullAll=Bg,v.pullAllBy=UO,v.pullAllWith=KO,v.pullAt=jO,v.range=uN,v.rangeRight=fN,v.rearg=oC,v.reject=qA,v.remove=qO,v.rest=lC,v.reverse=nu,v.sampleSize=GA,v.set=dM,v.setWith=hM,v.shuffle=YA,v.slice=JO,v.sortBy=ZA,v.sortedUniq=tA,v.sortedUniqBy=nA,v.split=LM,v.spread=aC,v.tail=rA,v.take=iA,v.takeRight=sA,v.takeRightWhile=oA,v.takeWhile=lA,v.tap=SA,v.throttle=cC,v.thru=Jo,v.toArray=Zg,v.toPairs=sy,v.toPairsIn=oy,v.toPath=gN,v.toPlainObject=ty,v.transform=pM,v.unary=uC,v.union=aA,v.unionBy=cA,v.unionWith=uA,v.uniq=fA,v.uniqBy=dA,v.uniqWith=hA,v.unset=mM,v.unzip=ru,v.unzipWith=Fg,v.update=gM,v.updateWith=yM,v.values=pi,v.valuesIn=_M,v.without=pA,v.words=cy,v.wrap=fC,v.xor=mA,v.xorBy=gA,v.xorWith=yA,v.zip=_A,v.zipObject=bA,v.zipObjectDeep=vA,v.zipWith=wA,v.entries=sy,v.entriesIn=oy,v.extend=ny,v.extendWith=tl,hu(v,v),v.add=_N,v.attempt=uy,v.camelCase=SM,v.capitalize=ly,v.ceil=bN,v.clamp=bM,v.clone=hC,v.cloneDeep=mC,v.cloneDeepWith=gC,v.cloneWith=pC,v.conformsTo=yC,v.deburr=ay,v.defaultTo=QM,v.divide=vN,v.endsWith=kM,v.eq=en,v.escape=xM,v.escapeRegExp=EM,v.every=IA,v.find=RA,v.findIndex=Pg,v.findKey=qC,v.findLast=DA,v.findLastIndex=Rg,v.findLastKey=JC,v.floor=wN,v.forEach=Wg,v.forEachRight=$g,v.forIn=GC,v.forInRight=YC,v.forOwn=QC,v.forOwnRight=XC,v.get=au,v.gt=_C,v.gte=bC,v.has=tM,v.hasIn=cu,v.head=Lg,v.identity=St,v.includes=WA,v.indexOf=DO,v.inRange=vM,v.invoke=iM,v.isArguments=Pr,v.isArray=se,v.isArrayBuffer=vC,v.isArrayLike=vt,v.isArrayLikeObject=Pe,v.isBoolean=wC,v.isBuffer=ir,v.isDate=SC,v.isElement=kC,v.isEmpty=xC,v.isEqual=EC,v.isEqualWith=TC,v.isError=ou,v.isFinite=OC,v.isFunction=Cn,v.isInteger=Gg,v.isLength=Zo,v.isMap=Yg,v.isMatch=AC,v.isMatchWith=CC,v.isNaN=MC,v.isNative=NC,v.isNil=PC,v.isNull=IC,v.isNumber=Qg,v.isObject=Ae,v.isObjectLike=Ie,v.isPlainObject=ds,v.isRegExp=lu,v.isSafeInteger=RC,v.isSet=Xg,v.isString=el,v.isSymbol=At,v.isTypedArray=hi,v.isUndefined=DC,v.isWeakMap=LC,v.isWeakSet=BC,v.join=WO,v.kebabCase=TM,v.last=Kt,v.lastIndexOf=$O,v.lowerCase=OM,v.lowerFirst=AM,v.lt=FC,v.lte=zC,v.max=SN,v.maxBy=kN,v.mean=xN,v.meanBy=EN,v.min=TN,v.minBy=ON,v.stubArray=mu,v.stubFalse=gu,v.stubObject=dN,v.stubString=hN,v.stubTrue=pN,v.multiply=AN,v.nth=VO,v.noConflict=iN,v.noop=pu,v.now=Yo,v.pad=CM,v.padEnd=MM,v.padStart=NM,v.parseInt=IM,v.random=wM,v.reduce=KA,v.reduceRight=jA,v.repeat=PM,v.replace=RM,v.result=fM,v.round=CN,v.runInContext=T,v.sample=JA,v.size=QA,v.snakeCase=DM,v.some=XA,v.sortedIndex=GO,v.sortedIndexBy=YO,v.sortedIndexOf=QO,v.sortedLastIndex=XO,v.sortedLastIndexBy=ZO,v.sortedLastIndexOf=eA,v.startCase=BM,v.startsWith=FM,v.subtract=MN,v.sum=NN,v.sumBy=IN,v.template=zM,v.times=mN,v.toFinite=Mn,v.toInteger=le,v.toLength=ey,v.toLower=WM,v.toNumber=jt,v.toSafeInteger=WC,v.toString=_e,v.toUpper=$M,v.trim=VM,v.trimEnd=HM,v.trimStart=UM,v.truncate=KM,v.unescape=jM,v.uniqueId=yN,v.upperCase=qM,v.upperFirst=uu,v.each=Wg,v.eachRight=$g,v.first=Lg,hu(v,function(){var o={};return un(v,function(a,f){be.call(v.prototype,f)||(o[f]=a)}),o}(),{chain:!1}),v.VERSION=r,Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){v[o].placeholder=v}),Wt(["drop","take"],function(o,a){he.prototype[o]=function(f){f=f===t?1:We(le(f),0);var m=this.__filtered__&&!a?new he(this):this.clone();return m.__filtered__?m.__takeCount__=st(f,m.__takeCount__):m.__views__.push({size:st(f,te),type:o+(m.__dir__<0?"Right":"")}),m},he.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),Wt(["filter","map","takeWhile"],function(o,a){var f=a+1,m=f==Ke||f==ft;he.prototype[o]=function(b){var w=this.clone();return w.__iteratees__.push({iteratee:X(b,3),type:f}),w.__filtered__=w.__filtered__||m,w}}),Wt(["head","last"],function(o,a){var f="take"+(a?"Right":"");he.prototype[o]=function(){return this[f](1).value()[0]}}),Wt(["initial","tail"],function(o,a){var f="drop"+(a?"":"Right");he.prototype[o]=function(){return this.__filtered__?new he(this):this[f](1)}}),he.prototype.compact=function(){return this.filter(St)},he.prototype.find=function(o){return this.filter(o).head()},he.prototype.findLast=function(o){return this.reverse().find(o)},he.prototype.invokeMap=fe(function(o,a){return typeof o=="function"?new he(this):this.map(function(f){return ss(f,o,a)})}),he.prototype.reject=function(o){return this.filter(Xo(X(o)))},he.prototype.slice=function(o,a){o=le(o);var f=this;return f.__filtered__&&(o>0||a<0)?new he(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),a!==t&&(a=le(a),f=a<0?f.dropRight(-a):f.take(a-o)),f)},he.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},he.prototype.toArray=function(){return this.take(te)},un(he.prototype,function(o,a){var f=/^(?:filter|find|map|reject)|While$/.test(a),m=/^(?:head|last)$/.test(a),b=v[m?"take"+(a=="last"?"Right":""):a],w=m||/^find/.test(a);b&&(v.prototype[a]=function(){var x=this.__wrapped__,E=m?[1]:arguments,O=x instanceof he,N=E[0],I=O||se(x),R=function(de){var pe=b.apply(v,Qn([de],E));return m&&$?pe[0]:pe};I&&f&&typeof N=="function"&&N.length!=1&&(O=I=!1);var $=this.__chain__,G=!!this.__actions__.length,Z=w&&!$,ce=O&&!G;if(!w&&I){x=ce?x:new he(this);var ee=o.apply(x,E);return ee.__actions__.push({func:Jo,args:[R],thisArg:t}),new Vt(ee,$)}return Z&&ce?o.apply(this,E):(ee=this.thru(R),Z?m?ee.value()[0]:ee.value():ee)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(o){var a=vo[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",m=/^(?:pop|shift)$/.test(o);v.prototype[o]=function(){var b=arguments;if(m&&!this.__chain__){var w=this.value();return a.apply(se(w)?w:[],b)}return this[f](function(x){return a.apply(se(x)?x:[],b)})}}),un(he.prototype,function(o,a){var f=v[a];if(f){var m=f.name+"";be.call(ai,m)||(ai[m]=[]),ai[m].push({name:a,func:f})}}),ai[$o(t,A).name]=[{name:"wrapper",func:t}],he.prototype.clone=jE,he.prototype.reverse=qE,he.prototype.value=JE,v.prototype.at=kA,v.prototype.chain=xA,v.prototype.commit=EA,v.prototype.next=TA,v.prototype.plant=AA,v.prototype.reverse=CA,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=MA,v.prototype.first=v.prototype.head,Xi&&(v.prototype[Xi]=OA),v},si=EE();Er?((Er.exports=si)._=si,dc._=si):Ze._=si}).call(mi)}(ks,ks.exports);var A_=ks.exports;const C_=sr.graphql(`
128
130
  query tournamentStepGeneratedShape($stepId: ID!) {
129
131
  tournamentStepGeneratedShape(stepId: $stepId) {
130
132
  id
@@ -145,7 +147,7 @@ function print() { __p += __j.call(arguments, '') }
145
147
  }
146
148
  }
147
149
  }
148
- `),M_=Pr.graphql(`
150
+ `),M_=sr.graphql(`
149
151
  query tournamentStepGroupRoundGameMatchScoresGetForStep($stepId: ID!, $page: PageInfo!) {
150
152
  tournamentStepGroupRoundGameMatchScoresGetForStep(
151
153
  stepId: $stepId
@@ -163,19 +165,19 @@ function print() { __p += __j.call(arguments, '') }
163
165
  }
164
166
  }
165
167
  }
166
- `),N_=({tournamentId:n,stepId:e,skip:t})=>{const{loading:r,data:i}=ml(C_,{variables:{stepId:e},skip:t}),{loading:s,results:l}=bl(M_,{skip:t,variables:{stepId:e}}),{loading:c,results:u}=Mf({tournamentId:n,skip:t,status:"CONFIRMED"});return{loading:r||s||c,groups:i==null?void 0:i.tournamentStepGeneratedShape.map(d=>{const h=A_.cloneDeep(d),p=u.reduce((g,_)=>(g[_.id]=_,g),{}),y={};for(const g of l){const _=p[g.teamId];if(!_){console.warn(`No team for score ${g.teamId}, match ${g.matchId}`);continue}const S=y[g.matchId]??[];y[g.matchId]=S.concat({..._,score:g.score})}for(const g of h.rounds)for(const _ of g.games)for(const S of _.matches)S.teamScores=y[S.id]??[];return h})}};function Ge(n){this.content=n}Ge.prototype={constructor:Ge,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Ge(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ge(t)},addToStart:function(n,e){return new Ge([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ge(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Ge(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ge.from(n),n.size?new Ge(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ge.from(n),n.size?new Ge(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ge.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ge.from=function(n){if(n instanceof Ge)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ge(e)};function Nf(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let l=0;i.text[l]==s.text[l];l++)t++;return t}if(i.content.size||s.content.size){let l=Nf(i.content,s.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function If(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let l=n.child(--i),c=e.child(--s),u=l.nodeSize;if(l==c){t-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:t,b:r};if(l.isText&&l.text!=c.text){let d=0,h=Math.min(l.text.length,c.text.length);for(;d<h&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(l.content.size||c.content.size){let d=If(l.content,c.content,t-1,r-1);if(d)return d}t-=u,r-=u}}class D{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let l=0,c=0;c<t;l++){let u=this.content[l],d=c+u.nodeSize;if(d>e&&r(u,i+c,s||null,l)!==!1&&u.content.size){let h=c+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,t-h),r,i+h)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",l=!0;return this.nodesBetween(e,t,(c,u)=>{let d=c.isText?c.text.slice(Math.max(e,u)-u,t-u):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&d||c.isTextblock)&&r&&(l?l=!1:s+=r),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new D(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,l=0;l<t;s++){let c=this.content[s],u=l+c.nodeSize;u>e&&((l<e||u>t)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,t-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,t-l-1))),r.push(c),i+=c.nodeSize),l=u}return new D(r,i)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new D(i,s)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Nf(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return If(this,e,t,r)}findIndex(e,t=-1){if(e==0)return xs(0,e);if(e==this.size)return xs(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),l=i+s.nodeSize;if(l>=e)return l==e||t>0?xs(r+1,l):xs(r,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Pl={index:0,offset:0};function xs(n,e){return Pl.index=n,Pl.offset=e,Pl}function Es(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Es(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Es(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let we=class yu{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Es(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return yu.none;if(e instanceof yu)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};we.none=[];class Ts extends Error{}class H{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Rf(this.content,e+this.openStart,t);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,t){return new H(Pf(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return H.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(D.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new H(e,r,i)}}H.empty=new H(D.empty,0,0);function Pf(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:l,offset:c}=n.findIndex(t);if(i==e||s.isText){if(c!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Pf(s.content,e-i-1,t-i-1)))}function Rf(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),l=n.maybeChild(i);if(s==e||l.isText)return n.cut(0,e).append(t).append(n.cut(e));let c=Rf(l.content,e-s-1,t);return c&&n.replaceChild(i,l.copy(c))}function I_(n,e,t){if(t.openStart>n.depth)throw new Ts("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ts("Inconsistent open depths");return Df(n,e,t,0)}function Df(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let l=Df(n,e,t,r+1);return s.copy(s.content.replaceChild(i,l))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let l=n.parent,c=l.content;return cr(l,c.cut(0,n.parentOffset).append(t.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=P_(t,n);return cr(s,Bf(n,l,c,e,r))}else return cr(s,Os(n,e,r))}function Lf(n,e){if(!e.type.compatibleContent(n.type))throw new Ts("Cannot join "+e.type.name+" onto "+n.type.name)}function Rl(n,e,t){let r=n.node(t);return Lf(r,e.node(t)),r}function ar(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ei(n,e,t,r){let i=(e||n).node(t),s=0,l=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(ar(n.nodeAfter,r),s++));for(let c=s;c<l;c++)ar(i.child(c),r);e&&e.depth==t&&e.textOffset&&ar(e.nodeBefore,r)}function cr(n,e){return n.type.checkContent(e),n.copy(e)}function Bf(n,e,t,r,i){let s=n.depth>i&&Rl(n,e,i+1),l=r.depth>i&&Rl(t,r,i+1),c=[];return Ei(null,n,i,c),s&&l&&e.index(i)==t.index(i)?(Lf(s,l),ar(cr(s,Bf(n,e,t,r,i+1)),c)):(s&&ar(cr(s,Os(n,e,i+1)),c),Ei(e,t,i,c),l&&ar(cr(l,Os(t,r,i+1)),c)),Ei(r,null,i,c),new D(c)}function Os(n,e,t){let r=[];if(Ei(null,n,t,r),n.depth>t){let i=Rl(n,e,t+1);ar(cr(i,Os(n,e,t+1)),r)}return Ei(e,null,t,r),new D(r)}function P_(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(D.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ti{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return we.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let c=r;r=i,i=c}let s=r.marks;for(var l=0;l<s.length;l++)s[l].type.spec.inclusive===!1&&(!i||!s[l].isInSet(i.marks))&&(s=s[l--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new As(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let l=e;;){let{index:c,offset:u}=l.content.findIndex(s),d=s-u;if(r.push(l,c,i+u),!d||(l=l.child(c),l.isText))break;s=d-1,i+=u+1}return new Ti(t,r,s)}static resolveCached(e,t){let r=Ff.get(e);if(r)for(let s=0;s<r.elts.length;s++){let l=r.elts[s];if(l.pos==t)return l}else Ff.set(e,r=new R_);let i=r.elts[r.i]=Ti.resolve(e,t);return r.i=(r.i+1)%D_,i}}class R_{constructor(){this.elts=[],this.i=0}}const D_=12,Ff=new WeakMap;class As{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const L_=Object.create(null);let Pn=class _u{constructor(e,t,r,i=we.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Es(this.attrs,t||e.defaultAttrs||L_)&&we.sameSet(this.marks,r||we.none)}copy(e=null){return e==this.content?this:new _u(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _u(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return H.empty;let i=this.resolve(e),s=this.resolve(t),l=r?0:i.sharedDepth(t),c=i.start(l),d=i.node(l).content.cut(i.pos-c,s.pos-c);return new H(d,i.depth-l,s.depth-l)}replace(e,t,r){return I_(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Ti.resolveCached(this,e)}resolveNoCache(e){return Ti.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),zf(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=D.empty,i=0,s=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,s),c=l&&l.matchFragment(this.content,t);if(!c||!c.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),l=s&&s.matchFragment(this.content,t);return l?l.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=we.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!we.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=D.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Pn.prototype.text=void 0;class Cs extends Pn{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Cs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Cs(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function zf(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ur{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new B_(e,t);if(r.next==null)return ur.empty;let i=Wf(r);r.next&&r.err("Unexpected trailing text");let s=U_(H_(i));return K_(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(l,c){let u=l.matchFragment(e,r);if(u&&(!t||u.validEnd))return D.from(c.map(d=>d.createAndFill()));for(let d=0;d<l.next.length;d++){let{type:h,next:p}=l.next[d];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(p)==-1){i.push(p);let y=s(p,c.concat(h));if(y)return y}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let l=[];for(let c=i;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<s.next.length;l++){let{type:c,next:u}=s.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in t)&&(!i.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:i}),t[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let l=0;l<r.next.length;l++)s+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return s}).join(`
167
- `)}}ur.empty=new ur(!0);class B_{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Wf(n){let e=[];do e.push(F_(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function F_(n){let e=[];do e.push(z_(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function z_(n){let e=V_(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=W_(n,e);else break;return e}function $f(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function W_(n,e){let t=$f(n),r=t;return n.eat(",")&&(n.next!="}"?r=$f(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function $_(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let l=t[s];l.isInGroup(e)&&i.push(l)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function V_(n){if(n.eat("(")){let e=Wf(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=$_(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function H_(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(l,c,u){let d={term:u,to:c};return e[l].push(d),d}function i(l,c){l.forEach(u=>u.to=c)}function s(l,c){if(l.type=="choice")return l.exprs.reduce((u,d)=>u.concat(s(d,c)),[]);if(l.type=="seq")for(let u=0;;u++){let d=s(l.exprs[u],c);if(u==l.exprs.length-1)return d;i(d,c=t())}else if(l.type=="star"){let u=t();return r(c,u),i(s(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=t();return i(s(l.expr,c),u),i(s(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(c)].concat(s(l.expr,c));if(l.type=="range"){let u=c;for(let d=0;d<l.min;d++){let h=t();i(s(l.expr,u),h),u=h}if(l.max==-1)i(s(l.expr,u),u);else for(let d=l.min;d<l.max;d++){let h=t();r(u,h),i(s(l.expr,u),h),u=h}return[r(u)]}else{if(l.type=="name")return[r(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function Vf(n,e){return e-n}function Hf(n,e){let t=[];return r(e),t.sort(Vf);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let l=0;l<s.length;l++){let{term:c,to:u}=s[l];!c&&t.indexOf(u)==-1&&r(u)}}}function U_(n){let e=Object.create(null);return t(Hf(n,0));function t(r){let i=[];r.forEach(l=>{n[l].forEach(({term:c,to:u})=>{if(!c)return;let d;for(let h=0;h<i.length;h++)i[h][0]==c&&(d=i[h][1]);Hf(n,u).forEach(h=>{d||i.push([c,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let s=e[r.join(",")]=new ur(r.indexOf(n.length-1)>-1);for(let l=0;l<i.length;l++){let c=i[l][1].sort(Vf);s.next.push({type:i[l][0],next:e[c.join(",")]||t(c)})}return s}}function K_(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,l=[];for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];l.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(d)==-1&&r.push(d)}s&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Uf(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Kf(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function jf(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function qf(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new q_(n,r,e[r]);return t}let Jf=class my{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=qf(e,r.attrs),this.defaultAttrs=Uf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ur.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Kf(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Pn(this,this.computeAttrs(e),D.from(t),we.setFrom(r))}createChecked(e=null,t,r){return t=D.from(t),this.checkContent(t),new Pn(this,this.computeAttrs(e),t,we.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=D.from(t),t.size){let l=this.contentMatch.fillBefore(t);if(!l)return null;t=l.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(D.empty,!0);return s?new Pn(this,e,t.append(s),we.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){jf(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:we.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,l)=>r[s]=new my(s,t,l));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function j_(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class q_{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?j_(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ms{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=qf(e,i.attrs),this.excluded=null;let s=Uf(this.attrs);this.instance=s?new we(this,s):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Kf(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,l)=>r[s]=new Ms(s,i++,t,l)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){jf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Gf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Ge.from(e.nodes),t.marks=Ge.from(e.marks||{}),this.nodes=Jf.compile(this.spec.nodes,this),this.marks=Ms.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],l=s.spec.content||"",c=s.spec.marks;if(s.contentMatch=r[l]||(r[l]=ur.parse(l,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=c=="_"?null:c?Yf(this,c.split(" ")):c==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],l=s.spec.excludes;s.excluded=l==null?[s]:l==""?[]:Yf(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jf){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Cs(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Pn.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Yf(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],l=s;if(s)t.push(s);else for(let c in n.marks){let u=n.marks[c];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&t.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function J_(n){return n.tag!=null}function G_(n){return n.style!=null}class Rn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(J_(i))this.tags.push(i);else if(G_(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new ed(this,t,!1);return r.addAll(e,we.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ed(this,t,!0);return r.addAll(e,we.none,t.from,t.to),H.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(X_(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let l=s.getAttrs(e);if(l===!1)continue;s.attrs=l||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let l=this.styles[s],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=t))){if(l.getAttrs){let u=l.getAttrs(t);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,l=0;for(;l<t.length;l++){let c=t[l];if((c.priority==null?50:c.priority)<s)break}t.splice(l,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(l=>{r(l=td(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(l=>{r(l=td(l)),l.node||l.ignore||l.mark||(l.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rn(e,Rn.schemaRules(e)))}}const Qf={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Y_={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xf={ol:!0,ul:!0},Oi=1,Dl=2,Ns=4;function Zf(n,e,t){return e!=null?(e?Oi:0)|(e==="full"?Dl:0):n&&n.whitespace=="pre"?Oi|Dl:t&-5}class Is{constructor(e,t,r,i,s,l){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=l,this.content=[],this.activeMarks=we.none,this.match=s||(l&Ns?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Oi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Qf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ed{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,l=Zf(null,t.preserveWhitespace,0)|(r?Ns:0);i?s=new Is(i.type,i.attrs,we.none,!0,t.topMatch||i.type.contentMatch,l):r?s=new Is(null,null,we.none,!0,null,l):s=new Is(e.schema.topNodeType,null,we.none,!0,null,l),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Dl?"full":this.localPreserveWS||(i.options&Oi)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
168
+ `),N_=({tournamentId:n,stepId:e,skip:t})=>{const{loading:r,data:i}=ml(C_,{variables:{stepId:e},skip:t}),{loading:s,results:l}=bl(M_,{skip:t,variables:{stepId:e}}),{loading:c,results:u}=Mf({tournamentId:n,skip:t,status:"CONFIRMED"});return{loading:r||s||c,groups:i==null?void 0:i.tournamentStepGeneratedShape.map(d=>{const h=A_.cloneDeep(d),p=u.reduce((g,_)=>(g[_.id]=_,g),{}),y={};for(const g of l){const _=p[g.teamId];if(!_){console.warn(`No team for score ${g.teamId}, match ${g.matchId}`);continue}const S=y[g.matchId]??[];y[g.matchId]=S.concat({..._,score:g.score})}for(const g of h.rounds)for(const _ of g.games)for(const S of _.matches)S.teamScores=y[S.id]??[];return h})}};function Ge(n){this.content=n}Ge.prototype={constructor:Ge,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Ge(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ge(t)},addToStart:function(n,e){return new Ge([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ge(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Ge(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ge.from(n),n.size?new Ge(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ge.from(n),n.size?new Ge(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ge.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ge.from=function(n){if(n instanceof Ge)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ge(e)};function Nf(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let l=0;i.text[l]==s.text[l];l++)t++;return t}if(i.content.size||s.content.size){let l=Nf(i.content,s.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function If(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let l=n.child(--i),c=e.child(--s),u=l.nodeSize;if(l==c){t-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:t,b:r};if(l.isText&&l.text!=c.text){let d=0,h=Math.min(l.text.length,c.text.length);for(;d<h&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(l.content.size||c.content.size){let d=If(l.content,c.content,t-1,r-1);if(d)return d}t-=u,r-=u}}class D{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let l=0,c=0;c<t;l++){let u=this.content[l],d=c+u.nodeSize;if(d>e&&r(u,i+c,s||null,l)!==!1&&u.content.size){let h=c+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,t-h),r,i+h)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",l=!0;return this.nodesBetween(e,t,(c,u)=>{let d=c.isText?c.text.slice(Math.max(e,u)-u,t-u):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&d||c.isTextblock)&&r&&(l?l=!1:s+=r),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new D(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,l=0;l<t;s++){let c=this.content[s],u=l+c.nodeSize;u>e&&((l<e||u>t)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,t-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,t-l-1))),r.push(c),i+=c.nodeSize),l=u}return new D(r,i)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new D(i,s)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Nf(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return If(this,e,t,r)}findIndex(e,t=-1){if(e==0)return xs(0,e);if(e==this.size)return xs(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),l=i+s.nodeSize;if(l>=e)return l==e||t>0?xs(r+1,l):xs(r,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Pl={index:0,offset:0};function xs(n,e){return Pl.index=n,Pl.offset=e,Pl}function Es(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Es(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Es(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let we=class yu{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Es(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return yu.none;if(e instanceof yu)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};we.none=[];class Ts extends Error{}class H{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Rf(this.content,e+this.openStart,t);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,t){return new H(Pf(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return H.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(D.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new H(e,r,i)}}H.empty=new H(D.empty,0,0);function Pf(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:l,offset:c}=n.findIndex(t);if(i==e||s.isText){if(c!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Pf(s.content,e-i-1,t-i-1)))}function Rf(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),l=n.maybeChild(i);if(s==e||l.isText)return n.cut(0,e).append(t).append(n.cut(e));let c=Rf(l.content,e-s-1,t);return c&&n.replaceChild(i,l.copy(c))}function I_(n,e,t){if(t.openStart>n.depth)throw new Ts("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ts("Inconsistent open depths");return Df(n,e,t,0)}function Df(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let l=Df(n,e,t,r+1);return s.copy(s.content.replaceChild(i,l))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let l=n.parent,c=l.content;return ur(l,c.cut(0,n.parentOffset).append(t.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=P_(t,n);return ur(s,Bf(n,l,c,e,r))}else return ur(s,Os(n,e,r))}function Lf(n,e){if(!e.type.compatibleContent(n.type))throw new Ts("Cannot join "+e.type.name+" onto "+n.type.name)}function Rl(n,e,t){let r=n.node(t);return Lf(r,e.node(t)),r}function cr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ei(n,e,t,r){let i=(e||n).node(t),s=0,l=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(cr(n.nodeAfter,r),s++));for(let c=s;c<l;c++)cr(i.child(c),r);e&&e.depth==t&&e.textOffset&&cr(e.nodeBefore,r)}function ur(n,e){return n.type.checkContent(e),n.copy(e)}function Bf(n,e,t,r,i){let s=n.depth>i&&Rl(n,e,i+1),l=r.depth>i&&Rl(t,r,i+1),c=[];return Ei(null,n,i,c),s&&l&&e.index(i)==t.index(i)?(Lf(s,l),cr(ur(s,Bf(n,e,t,r,i+1)),c)):(s&&cr(ur(s,Os(n,e,i+1)),c),Ei(e,t,i,c),l&&cr(ur(l,Os(t,r,i+1)),c)),Ei(r,null,i,c),new D(c)}function Os(n,e,t){let r=[];if(Ei(null,n,t,r),n.depth>t){let i=Rl(n,e,t+1);cr(ur(i,Os(n,e,t+1)),r)}return Ei(e,null,t,r),new D(r)}function P_(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(D.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ti{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return we.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let c=r;r=i,i=c}let s=r.marks;for(var l=0;l<s.length;l++)s[l].type.spec.inclusive===!1&&(!i||!s[l].isInSet(i.marks))&&(s=s[l--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new As(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let l=e;;){let{index:c,offset:u}=l.content.findIndex(s),d=s-u;if(r.push(l,c,i+u),!d||(l=l.child(c),l.isText))break;s=d-1,i+=u+1}return new Ti(t,r,s)}static resolveCached(e,t){let r=Ff.get(e);if(r)for(let s=0;s<r.elts.length;s++){let l=r.elts[s];if(l.pos==t)return l}else Ff.set(e,r=new R_);let i=r.elts[r.i]=Ti.resolve(e,t);return r.i=(r.i+1)%D_,i}}class R_{constructor(){this.elts=[],this.i=0}}const D_=12,Ff=new WeakMap;class As{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const L_=Object.create(null);let Pn=class _u{constructor(e,t,r,i=we.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Es(this.attrs,t||e.defaultAttrs||L_)&&we.sameSet(this.marks,r||we.none)}copy(e=null){return e==this.content?this:new _u(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _u(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return H.empty;let i=this.resolve(e),s=this.resolve(t),l=r?0:i.sharedDepth(t),c=i.start(l),d=i.node(l).content.cut(i.pos-c,s.pos-c);return new H(d,i.depth-l,s.depth-l)}replace(e,t,r){return I_(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Ti.resolveCached(this,e)}resolveNoCache(e){return Ti.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),zf(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=D.empty,i=0,s=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,s),c=l&&l.matchFragment(this.content,t);if(!c||!c.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),l=s&&s.matchFragment(this.content,t);return l?l.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=we.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!we.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=D.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Pn.prototype.text=void 0;class Cs extends Pn{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Cs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Cs(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function zf(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class fr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new B_(e,t);if(r.next==null)return fr.empty;let i=Wf(r);r.next&&r.err("Unexpected trailing text");let s=U_(H_(i));return K_(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(l,c){let u=l.matchFragment(e,r);if(u&&(!t||u.validEnd))return D.from(c.map(d=>d.createAndFill()));for(let d=0;d<l.next.length;d++){let{type:h,next:p}=l.next[d];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(p)==-1){i.push(p);let y=s(p,c.concat(h));if(y)return y}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let l=[];for(let c=i;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<s.next.length;l++){let{type:c,next:u}=s.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in t)&&(!i.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:i}),t[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let l=0;l<r.next.length;l++)s+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return s}).join(`
169
+ `)}}fr.empty=new fr(!0);class B_{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Wf(n){let e=[];do e.push(F_(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function F_(n){let e=[];do e.push(z_(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function z_(n){let e=V_(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=W_(n,e);else break;return e}function $f(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function W_(n,e){let t=$f(n),r=t;return n.eat(",")&&(n.next!="}"?r=$f(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function $_(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let l=t[s];l.isInGroup(e)&&i.push(l)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function V_(n){if(n.eat("(")){let e=Wf(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=$_(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function H_(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(l,c,u){let d={term:u,to:c};return e[l].push(d),d}function i(l,c){l.forEach(u=>u.to=c)}function s(l,c){if(l.type=="choice")return l.exprs.reduce((u,d)=>u.concat(s(d,c)),[]);if(l.type=="seq")for(let u=0;;u++){let d=s(l.exprs[u],c);if(u==l.exprs.length-1)return d;i(d,c=t())}else if(l.type=="star"){let u=t();return r(c,u),i(s(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=t();return i(s(l.expr,c),u),i(s(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(c)].concat(s(l.expr,c));if(l.type=="range"){let u=c;for(let d=0;d<l.min;d++){let h=t();i(s(l.expr,u),h),u=h}if(l.max==-1)i(s(l.expr,u),u);else for(let d=l.min;d<l.max;d++){let h=t();r(u,h),i(s(l.expr,u),h),u=h}return[r(u)]}else{if(l.type=="name")return[r(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function Vf(n,e){return e-n}function Hf(n,e){let t=[];return r(e),t.sort(Vf);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let l=0;l<s.length;l++){let{term:c,to:u}=s[l];!c&&t.indexOf(u)==-1&&r(u)}}}function U_(n){let e=Object.create(null);return t(Hf(n,0));function t(r){let i=[];r.forEach(l=>{n[l].forEach(({term:c,to:u})=>{if(!c)return;let d;for(let h=0;h<i.length;h++)i[h][0]==c&&(d=i[h][1]);Hf(n,u).forEach(h=>{d||i.push([c,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let s=e[r.join(",")]=new fr(r.indexOf(n.length-1)>-1);for(let l=0;l<i.length;l++){let c=i[l][1].sort(Vf);s.next.push({type:i[l][0],next:e[c.join(",")]||t(c)})}return s}}function K_(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,l=[];for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];l.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(d)==-1&&r.push(d)}s&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Uf(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Kf(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function jf(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function qf(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new q_(n,r,e[r]);return t}let Jf=class my{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=qf(e,r.attrs),this.defaultAttrs=Uf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==fr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Kf(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Pn(this,this.computeAttrs(e),D.from(t),we.setFrom(r))}createChecked(e=null,t,r){return t=D.from(t),this.checkContent(t),new Pn(this,this.computeAttrs(e),t,we.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=D.from(t),t.size){let l=this.contentMatch.fillBefore(t);if(!l)return null;t=l.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(D.empty,!0);return s?new Pn(this,e,t.append(s),we.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){jf(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:we.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,l)=>r[s]=new my(s,t,l));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function j_(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class q_{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?j_(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ms{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=qf(e,i.attrs),this.excluded=null;let s=Uf(this.attrs);this.instance=s?new we(this,s):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Kf(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,l)=>r[s]=new Ms(s,i++,t,l)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){jf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Gf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Ge.from(e.nodes),t.marks=Ge.from(e.marks||{}),this.nodes=Jf.compile(this.spec.nodes,this),this.marks=Ms.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],l=s.spec.content||"",c=s.spec.marks;if(s.contentMatch=r[l]||(r[l]=fr.parse(l,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=c=="_"?null:c?Yf(this,c.split(" ")):c==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],l=s.spec.excludes;s.excluded=l==null?[s]:l==""?[]:Yf(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Jf){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Cs(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Pn.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Yf(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],l=s;if(s)t.push(s);else for(let c in n.marks){let u=n.marks[c];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&t.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function J_(n){return n.tag!=null}function G_(n){return n.style!=null}class Rn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(J_(i))this.tags.push(i);else if(G_(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new ed(this,t,!1);return r.addAll(e,we.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ed(this,t,!0);return r.addAll(e,we.none,t.from,t.to),H.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(X_(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let l=s.getAttrs(e);if(l===!1)continue;s.attrs=l||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let l=this.styles[s],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=t))){if(l.getAttrs){let u=l.getAttrs(t);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,l=0;for(;l<t.length;l++){let c=t[l];if((c.priority==null?50:c.priority)<s)break}t.splice(l,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(l=>{r(l=td(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(l=>{r(l=td(l)),l.node||l.ignore||l.mark||(l.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rn(e,Rn.schemaRules(e)))}}const Qf={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Y_={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xf={ol:!0,ul:!0},Oi=1,Dl=2,Ns=4;function Zf(n,e,t){return e!=null?(e?Oi:0)|(e==="full"?Dl:0):n&&n.whitespace=="pre"?Oi|Dl:t&-5}class Is{constructor(e,t,r,i,s,l){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=l,this.content=[],this.activeMarks=we.none,this.match=s||(l&Ns?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Oi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Qf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ed{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,l=Zf(null,t.preserveWhitespace,0)|(r?Ns:0);i?s=new Is(i.type,i.attrs,we.none,!0,t.topMatch||i.type.contentMatch,l):r?s=new Is(null,null,we.none,!0,null,l):s=new Is(e.schema.topNodeType,null,we.none,!0,null,l),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Dl?"full":this.localPreserveWS||(i.options&Oi)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
168
170
  `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),c;Xf.hasOwnProperty(l)&&this.parser.normalizeLists&&Q_(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:Y_.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,t);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let d,h=this.needsBlock;if(Qf.hasOwnProperty(l))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),d=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let p=u&&u.skip?t:this.readStyles(e,t);p&&this.addAll(e,p),d&&this.sync(s),this.needsBlock=h}else{let d=this.readStyles(e,t);d&&this.addElementByRule(e,u,d,u.consuming===!1?c:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
169
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],l=r.getPropertyValue(s);if(l)for(let c=void 0;;){let u=this.parser.matchStyle(s,l,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?t=t.filter(d=>!u.clearMark(d)):t=t.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return t}addElementByRule(e,t,r,i){let s,l;if(t.node)if(l=this.parser.schema.nodes[t.node],l.isLeaf)this.insertNode(l.create(t.attrs),r)||this.leafFallback(e,r);else{let u=this.enter(l,t.attrs||null,r,t.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[t.mark];r=r.concat(u.create(t.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r));else{let u=e;typeof t.contentElement=="string"?u=e.querySelector(t.contentElement):typeof t.contentElement=="function"?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}s&&this.sync(c)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];l!=c;l=l.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(l,t);this.findAtPoint(e,s)}findPlace(e,t){let r,i;for(let s=this.open;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!r||r.length>c.length)&&(r=c,i=l,!c.length)||l.solid)break}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=we.none;for(let l of r.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):nd(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let c=Zf(e,s,l.options);l.options&Ns&&l.content.length==0&&(c|=Ns);let u=we.none;return r=r.filter(d=>(l.type?l.type.allowsMarkType(d.type):nd(d.type,e))?(u=d.addToSet(u),!1):!0),this.nodes.push(new Is(e,t,u,i,null,c)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Oi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let d=t[c];if(d==""){if(c==t.length-1||c==0)continue;for(;u>=s;u--)if(l(c-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!h||h.name!=d&&!h.isInGroup(d))return!1;u--}}return!0};return l(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Q_(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xf.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function X_(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function td(n){let e={};for(let t in n)e[t]=n[t];return e}function nd(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],l=c=>{s.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:h}=c.edge(u);if(d==e||s.indexOf(h)<0&&l(h))return!0}};if(l(i.contentMatch))return!0}}class fr{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Ll(t).createDocumentFragment());let i=r,s=[];return e.forEach(l=>{if(s.length||l.marks.length){let c=0,u=0;for(;c<s.length&&u<l.marks.length;){let d=l.marks[u];if(!this.marks[d.type.name]){u++;continue}if(!d.eq(s[c][0])||d.type.spec.spanning===!1)break;c++,u++}for(;c<s.length;)i=s.pop()[1];for(;u<l.marks.length;){let d=l.marks[u++],h=this.serializeMark(d,l.isInline,t);h&&(s.push([d,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(l,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Ps(Ll(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ps(Ll(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ps(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new fr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=rd(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return rd(e.marks)}}function rd(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ll(n){return n.document||window.document}const id=new WeakMap;function Z_(n){let e=id.get(n);return e===void 0&&id.set(n,e=eb(n)),e}function eb(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Ps(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Z_(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=i.indexOf(" ");l>0&&(t=i.slice(0,l),i=i.slice(l+1));let c,u=t?n.createElementNS(t,i):n.createElement(i),d=e[1],h=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){h=2;for(let p in d)if(d[p]!=null){let y=p.indexOf(" ");y>0?u.setAttributeNS(p.slice(0,y),p.slice(y+1),d[p]):u.setAttribute(p,d[p])}}for(let p=h;p<e.length;p++){let y=e[p];if(y===0){if(p<e.length-1||p>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:g,contentDOM:_}=Ps(n,y,t,r);if(u.appendChild(g),_){if(c)throw new RangeError("Multiple content holes");c=_}}}return{dom:u,contentDOM:c}}const sd=65535,od=Math.pow(2,16);function tb(n,e){return n+e*od}function ld(n){return n&sd}function nb(n){return(n-(n&sd))/od}const ad=1,cd=2,Rs=4,ud=8;class Bl{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ud)>0}get deletedBefore(){return(this.delInfo&(ad|Rs))>0}get deletedAfter(){return(this.delInfo&(cd|Rs))>0}get deletedAcross(){return(this.delInfo&Rs)>0}}class kt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&kt.empty)return kt.empty}recover(e){let t=0,r=ld(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+nb(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let d=this.ranges[c+s],h=this.ranges[c+l],p=u+d;if(e<=p){let y=d?e==u?-1:e==p?1:t:t,g=u+i+(y<0?0:h);if(r)return g;let _=e==(t<0?u:p)?null:tb(c/3,e-u),S=e==u?cd:e==p?ad:Rs;return(t<0?e!=u:e!=p)&&(S|=ud),new Bl(g,S,_)}i+=h-d}return r?e+i:new Bl(e+i,0,null)}touches(e,t){let r=0,i=ld(t),s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let d=this.ranges[c+s],h=u+d;if(e<=h&&c==i*3)return!0;r+=this.ranges[c+l]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?s:0),u=l+(this.inverted?0:s),d=this.ranges[i+t],h=this.ranges[i+r];e(c,c+d,u,u+h),s+=h-d}}invert(){return new kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?kt.empty:new kt(e<0?[0,-e,0]:[0,0,e])}}kt.empty=new kt([]);class Ai{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Ai(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ai;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let l=this._maps[s],c=l.mapResult(e,t);if(c.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(c.recover);continue}}i|=c.delInfo,e=c.pos}return r?e:new Bl(e,i,null)}}const Fl=Object.create(null);class tt{getMap(){return kt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Fl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Fl)throw new RangeError("Duplicate use of step JSON ID "+e);return Fl[e]=t,t.prototype.jsonID=e,t}}class De{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new De(e,null)}static fail(e){return new De(null,e)}static fromReplace(e,t,r,i){try{return De.ok(e.replace(t,r,i))}catch(s){if(s instanceof Ts)return De.fail(s.message);throw s}}}function zl(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(zl(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return D.fromArray(r)}class Dn extends tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new H(zl(t.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,s)}invert(){return new rn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Dn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Dn(t.from,t.to,e.markFromJSON(t.mark))}}tt.jsonID("addMark",Dn);class rn extends tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new H(zl(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,r)}invert(){return new Dn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rn(t.pos,r.pos,this.mark)}merge(e){return e instanceof rn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rn(t.from,t.to,e.markFromJSON(t.mark))}}tt.jsonID("removeMark",rn);class Ln extends tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Ln(this.pos,t.marks[i]);return new Ln(this.pos,this.mark)}}return new zr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ln(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ln(t.pos,e.markFromJSON(t.mark))}}tt.jsonID("addNodeMark",Ln);class zr extends tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ln(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new zr(t.pos,e.markFromJSON(t.mark))}}tt.jsonID("removeNodeMark",zr);class $e extends tt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Wl(e,this.from,this.to)?De.fail("Structure replace would overwrite content"):De.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new kt([this.from,this.to-this.from,this.slice.size])}invert(e){return new $e(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new $e(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof $e)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $e(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $e(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $e(t.from,t.to,H.fromJSON(e,t.slice),!!t.structure)}}tt.jsonID("replace",$e);class Ve extends tt{constructor(e,t,r,i,s,l,c=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=l,this.structure=c}apply(e){if(this.structure&&(Wl(e,this.from,this.gapFrom)||Wl(e,this.gapTo,this.to)))return De.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return De.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?De.fromReplace(e,this.from,this.to,r):De.fail("Content does not fit in gap")}getMap(){return new kt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ve(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ve(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ve(t.from,t.to,t.gapFrom,t.gapTo,H.fromJSON(e,t.slice),t.insert,!!t.structure)}}tt.jsonID("replaceAround",Ve);function Wl(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let l=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function rb(n,e,t,r){let i=[],s=[],l,c;n.doc.nodesBetween(e,t,(u,d,h)=>{if(!u.isInline)return;let p=u.marks;if(!r.isInSet(p)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),g=Math.min(d+u.nodeSize,t),_=r.addToSet(p);for(let S=0;S<p.length;S++)p[S].isInSet(_)||(l&&l.to==y&&l.mark.eq(p[S])?l.to=g:i.push(l=new rn(y,g,p[S])));c&&c.to==y?c.to=g:s.push(c=new Dn(y,g,r))}}),i.forEach(u=>n.step(u)),s.forEach(u=>n.step(u))}function ib(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(l,c)=>{if(!l.isInline)return;s++;let u=null;if(r instanceof Ms){let d=l.marks,h;for(;h=r.isInSet(d);)(u||(u=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let d=Math.min(c+l.nodeSize,t);for(let h=0;h<u.length;h++){let p=u[h],y;for(let g=0;g<i.length;g++){let _=i[g];_.step==s-1&&p.eq(i[g].style)&&(y=_)}y?(y.to=d,y.step=s):i.push({style:p,from:Math.max(c,e),to:d,step:s})}}}),i.forEach(l=>n.step(new rn(l.from,l.to,l.style)))}function $l(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),l=[],c=e+1;for(let u=0;u<s.childCount;u++){let d=s.child(u),h=c+d.nodeSize,p=r.matchType(d.type);if(!p)l.push(new $e(c,h,H.empty));else{r=p;for(let y=0;y<d.marks.length;y++)t.allowsMarkType(d.marks[y].type)||n.step(new rn(c,h,d.marks[y]));if(i&&d.isText&&t.whitespace!="pre"){let y,g=/\r?\n|\r/g,_;for(;y=g.exec(d.text);)_||(_=new H(D.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),l.push(new $e(c+y.index,c+y.index+y[0].length,_))}}c=h}if(!r.validEnd){let u=r.fillBefore(D.empty,!0);n.replace(c,c,new H(u,0,0))}for(let u=l.length-1;u>=0;u--)n.step(l[u])}function sb(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Wr(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),l=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,l,t))return r;if(r==0||i.type.spec.isolating||!sb(i,s,l))break}return null}function ob(n,e,t){let{$from:r,$to:i,depth:s}=e,l=r.before(s+1),c=i.after(s+1),u=l,d=c,h=D.empty,p=0;for(let _=s,S=!1;_>t;_--)S||r.index(_)>0?(S=!0,h=D.from(r.node(_).copy(h)),p++):u--;let y=D.empty,g=0;for(let _=s,S=!1;_>t;_--)S||i.after(_+1)<i.end(_)?(S=!0,y=D.from(i.node(_).copy(y)),g++):d++;n.step(new Ve(u,d,l,c,new H(h.append(y),p,g),h.size-p,!0))}function Vl(n,e,t=null,r=n){let i=lb(n,e),s=i&&ab(r,e);return s?i.map(fd).concat({type:e,attrs:t}).concat(s.map(fd)):null}function fd(n){return{type:n,attrs:null}}function lb(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return t.canReplaceWith(r,i,l)?s:null}function ab(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),l=e.contentMatch.findWrapping(s.type);if(!l)return null;let u=(l.length?l[l.length-1]:e).contentMatch;for(let d=r;u&&d<i;d++)u=u.matchType(t.child(d).type);return!u||!u.validEnd?null:l}function cb(n,e,t){let r=D.empty;for(let l=t.length-1;l>=0;l--){if(r.size){let c=t[l].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=D.from(t[l].type.create(t[l].attrs,r))}let i=e.start,s=e.end;n.step(new Ve(i,s,i,s,new H(r,0,0),t.length,!0))}function ub(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(l,c)=>{let u=typeof i=="function"?i(l):i;if(l.isTextblock&&!l.hasMarkup(r,u)&&fb(n.doc,n.mapping.slice(s).map(c),r)){let d=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",_=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!_?d=!1:!g&&_&&(d=!0)}d===!1&&hd(n,l,c,s),$l(n,n.mapping.slice(s).map(c,1),r,void 0,d===null);let h=n.mapping.slice(s),p=h.map(c,1),y=h.map(c+l.nodeSize,1);return n.step(new Ve(p,y,p+1,y-1,new H(D.from(r.create(u,null,l.marks)),0,0),1,!0)),d===!0&&dd(n,l,c,s),!1}})}function dd(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(i.text);){let u=n.mapping.slice(r).map(t+1+s+l.index);n.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function hd(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let l=n.mapping.slice(r).map(t+1+s);n.replaceWith(l,l+1,e.type.schema.text(`
170
- `))}})}function fb(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function db(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let l=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,l);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ve(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new H(D.from(l),0,0),1,!0))}function gn(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,l=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>s;d--,h--){let p=i.node(d),y=i.index(d);if(p.type.spec.isolating)return!1;let g=p.content.cutByIndex(y,p.childCount),_=r&&r[h+1];_&&(g=g.replaceChild(0,_.type.create(_.attrs)));let S=r&&r[h]||p;if(!p.canReplace(y+1,p.childCount)||!S.type.validContent(g))return!1}let c=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(c,c,u?u.type:i.node(s+1).type)}function hb(n,e,t=1,r){let i=n.doc.resolve(e),s=D.empty,l=D.empty;for(let c=i.depth,u=i.depth-t,d=t-1;c>u;c--,d--){s=D.from(i.node(c).copy(s));let h=r&&r[d];l=D.from(h?h.type.create(h.attrs,l):i.node(c).copy(l))}n.step(new $e(e,e,new H(s.append(l),t,t),!0))}function Bn(n,e){let t=n.resolve(e),r=t.index();return pd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function pb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),l=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(l),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function pd(n,e){return!!(n&&e&&!n.isLeaf&&pb(n,e))}function Ds(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,l,c=r.index(i);if(i==r.depth?(s=r.nodeBefore,l=r.nodeAfter):t>0?(s=r.node(i+1),c++,l=r.node(i).maybeChild(c)):(s=r.node(i).maybeChild(c-1),l=r.node(i+1)),s&&!s.isTextblock&&pd(s,l)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function mb(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),l=s.node().type;if(i&&l.inlineContent){let h=l.whitespace=="pre",p=!!l.contentMatch.matchType(i);h&&!p?r=!1:!h&&p&&(r=!0)}let c=n.steps.length;if(r===!1){let h=n.doc.resolve(e+t);hd(n,h.node(),h.before(),c)}l.inlineContent&&$l(n,e+t-1,l,s.node().contentMatchAt(s.index()),r==null);let u=n.mapping.slice(c),d=u.map(e-t);if(n.step(new $e(d,u.map(e+t,-1),H.empty,!0)),r===!0){let h=n.doc.resolve(d);dd(n,h.node(),h.before(),n.steps.length)}return n}function gb(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function md(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let l=r.depth;l>=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(c>0?1:0),d=r.node(l),h=!1;if(s==1)h=d.canReplace(u,u,i);else{let p=d.contentMatchAt(u).findWrapping(i.firstChild.type);h=p&&d.canReplaceWith(u,u,p[0])}if(h)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Ls(n,e,t=e,r=H.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return gd(i,s,r)?new $e(e,t,r):new yb(i,s,r).fit()}function gd(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class yb{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=D.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=D.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,l=r.depth,c=i.depth;for(;l&&c&&s.childCount==1;)s=s.firstChild.content,l--,c--;let u=new H(s,l,c);return e>-1?new Ve(r.pos,e,this.$to.pos,this.$to.end(),u,t):u.size||r.pos!=this.$to.pos?new $e(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Hl(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let l=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:d}=this.frontier[c],h,p=null;if(t==1&&(l?d.matchType(l.type)||(p=d.fillBefore(D.from(l),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:c,parent:s,inject:p};if(t==2&&l&&(h=d.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:s,wrap:h};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Hl(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new H(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Hl(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new H(Ci(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new H(Ci(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let S=0;S<s.length;S++)this.openFrontierNode(s[S]);let l=this.unplaced,c=r?r.content:l.content,u=l.openStart-e,d=0,h=[],{match:p,type:y}=this.frontier[t];if(i){for(let S=0;S<i.childCount;S++)h.push(i.child(S));p=p.matchFragment(i)}let g=c.size+e-(l.content.size-l.openEnd);for(;d<c.childCount;){let S=c.child(d),k=p.matchType(S.type);if(!k)break;d++,(d>1||u==0||S.content.size)&&(p=k,h.push(yd(S.mark(y.allowedMarks(S.marks)),d==1?u:0,d==c.childCount?g:-1)))}let _=d==c.childCount;_||(g=-1),this.placed=Mi(this.placed,t,D.from(h)),this.frontier[t].match=p,_&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let S=0,k=c;S<g;S++){let A=k.lastChild;this.frontier.push({type:A.type,match:A.contentMatchAt(A.childCount)}),k=A.content}this.unplaced=_?e==0?H.empty:new H(Ci(l.content,e-1,1),e-1,g<0?l.openEnd:e-1):new H(Ci(l.content,e,d),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ul(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),l=Ul(e,t,i,r,s);if(l){for(let c=t-1;c>=0;c--){let{match:u,type:d}=this.frontier[c],h=Ul(e,c,d,u,!0);if(!h||h.childCount)continue e}return{depth:t,fit:l,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Mi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mi(this.placed,this.depth,D.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(D.empty,!0);t.childCount&&(this.placed=Mi(this.placed,this.frontier.length,t))}}function Ci(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ci(n.firstChild.content,e-1,t)))}function Mi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Mi(n.lastChild.content,e-1,t)))}function Hl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function yd(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,yd(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(D.empty,!0)))),n.copy(r)}function Ul(n,e,t,r,i){let s=n.node(e),l=i?n.indexAfter(e):n.index(e);if(l==s.childCount&&!t.compatibleContent(s.type))return null;let c=r.fillBefore(s.content,!0,l);return c&&!_b(t,s.content,l)?c:null}function _b(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function bb(n){return n.spec.defining||n.spec.definingForContent}function vb(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(gd(i,s,r))return n.step(new $e(e,t,r));let l=bd(i,n.doc.resolve(t));l[l.length-1]==0&&l.pop();let c=-(i.depth+1);l.unshift(c);for(let y=i.depth,g=i.pos-1;y>0;y--,g--){let _=i.node(y).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(y)>-1?c=y:i.before(y)==g&&l.splice(1,0,-y)}let u=l.indexOf(c),d=[],h=r.openStart;for(let y=r.content,g=0;;g++){let _=y.firstChild;if(d.push(_),g==r.openStart)break;y=_.content}for(let y=h-1;y>=0;y--){let g=d[y],_=bb(g.type);if(_&&!g.sameMarkup(i.node(Math.abs(c)-1)))h=y;else if(_||!g.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let g=(y+h+1)%(r.openStart+1),_=d[g];if(_)for(let S=0;S<l.length;S++){let k=l[(S+u)%l.length],A=!0;k<0&&(A=!1,k=-k);let P=i.node(k-1),L=i.index(k-1);if(P.canReplaceWith(L,L,_.type,_.marks))return n.replace(i.before(k),A?s.after(k):t,new H(_d(r.content,0,r.openStart,g),g,r.openEnd))}}let p=n.steps.length;for(let y=l.length-1;y>=0&&(n.replace(e,t,r),!(n.steps.length>p));y--){let g=l[y];g<0||(e=i.before(g),t=s.after(g))}}function _d(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(_d(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),l=s.fillBefore(n).append(n);n=l.append(s.matchFragment(l).fillBefore(D.empty,!0))}return n}function wb(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=gb(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new H(D.from(r),0,0))}function Sb(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=bd(r,i);for(let l=0;l<s.length;l++){let c=s[l],u=l==s.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return n.delete(r.start(c),i.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return n.delete(r.before(c),i.after(c))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&t>r.end(l)&&i.end(l)-t!=i.depth-l&&r.start(l-1)==i.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),i.index(l-1)))return n.delete(r.before(l),t);n.delete(e,t)}function bd(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class $r extends tt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(i),0,t.isLeaf?0:1))}getMap(){return kt.empty}invert(e){return new $r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new $r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new $r(t.pos,t.attr,t.value)}}tt.jsonID("attr",$r);class Ni extends tt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return De.ok(r)}getMap(){return kt.empty}invert(e){return new Ni(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ni(t.attr,t.value)}}tt.jsonID("docAttr",Ni);let Vr=class extends Error{};Vr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Vr.prototype=Object.create(Error.prototype),Vr.prototype.constructor=Vr,Vr.prototype.name="TransformError";class kb{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ai}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=H.empty){let i=Ls(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new H(D.from(r),0,0))}delete(e,t){return this.replace(e,t,H.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return vb(this,e,t,r),this}replaceRangeWith(e,t,r){return wb(this,e,t,r),this}deleteRange(e,t){return Sb(this,e,t),this}lift(e,t){return ob(this,e,t),this}join(e,t=1){return mb(this,e,t),this}wrap(e,t){return cb(this,e,t),this}setBlockType(e,t=e,r,i=null){return ub(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return db(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new $r(e,t,r)),this}setDocAttribute(e,t){return this.step(new Ni(e,t)),this}addNodeMark(e,t){return this.step(new Ln(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new zr(e,t)),this}split(e,t=1,r){return hb(this,e,t,r),this}addMark(e,t,r){return rb(this,e,t,r),this}removeMark(e,t,r){return ib(this,e,t,r),this}clearIncompatible(e,t,r){return $l(this,e,t,r),this}}const Kl=Object.create(null);class oe{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new xb(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=H.empty){let r=t.content.lastChild,i=null;for(let c=0;c<t.openEnd;c++)i=r,r=r.lastChild;let s=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],h=e.mapping.slice(s);e.replaceRange(h.map(u.pos),h.map(d.pos),c?H.empty:t),c==0&&Sd(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:c}=i[s],u=e.mapping.slice(r),d=u.map(l.pos),h=u.map(c.pos);s?e.deleteRange(d,h):(e.replaceRangeWith(d,h,t),Sd(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new re(e):Hr(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let l=t<0?Hr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Hr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new xt(e.node(0))}static atStart(e){return Hr(e,e,0,0,1)||new xt(e)}static atEnd(e){return Hr(e,e,e.content.size,e.childCount,-1)||new xt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kl[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class xb{constructor(e,t){this.$from=e,this.$to=t}}let vd=!1;function wd(n){!vd&&!n.parent.inlineContent&&(vd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends oe{constructor(e,t=e){wd(e),wd(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return oe.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=H.empty){if(super.replace(e,t),t==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=oe.findFrom(t,r,!0)||oe.findFrom(t,-r,!0);if(s)t=s.$head;else return oe.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(oe.findFrom(e,-r,!0)||oe.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new re(e,t)}}oe.jsonID("text",re);class Bs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Bs(e.map(this.anchor),e.map(this.head))}resolve(e){return re.between(e.resolve(this.anchor),e.resolve(this.head))}}class Q extends oe{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?oe.near(s):new Q(s)}content(){return new H(D.from(this.node),0,0)}eq(e){return e instanceof Q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new jl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Q(e.resolve(t.anchor))}static create(e,t){return new Q(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Q.prototype.visible=!1,oe.jsonID("node",Q);class jl{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Bs(r,r):new jl(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Q.isSelectable(r)?new Q(t):oe.near(t)}}class xt extends oe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=H.empty){if(t==H.empty){e.delete(0,e.doc.content.size);let r=oe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new xt(e)}map(e){return new xt(e)}eq(e){return e instanceof xt}getBookmark(){return Eb}}oe.jsonID("all",xt);const Eb={map(){return this},resolve(n){return new xt(n)}};function Hr(n,e,t,r,i,s=!1){if(e.inlineContent)return re.create(n,t);for(let l=r-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let c=e.child(l);if(c.isAtom){if(!s&&Q.isSelectable(c))return Q.create(n,t-(i<0?c.nodeSize:0))}else{let u=Hr(n,c,t+i,i<0?c.childCount:0,i,s);if(u)return u}t+=c.nodeSize*i}return null}function Sd(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof $e||i instanceof Ve))return;let s=n.mapping.maps[r],l;s.forEach((c,u,d,h)=>{l==null&&(l=h)}),n.setSelection(oe.near(n.doc.resolve(l),t))}const kd=1,xd=2,Ed=4;class Tb extends kb{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|kd)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&kd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=xd,this}ensureMarks(e){return we.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&xd)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let l=this.doc.resolve(t);s=r==t?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(oe.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ed,this}get scrolledIntoView(){return(this.updated&Ed)>0}}function Td(n,e){return!e||!n?n:n.bind(e)}class Ii{constructor(e,t,r){this.name=e,this.init=Td(t.init,r),this.apply=Td(t.apply,r)}}const Ob=[new Ii("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ii("selection",{init(n,e){return n.selection||oe.atStart(e.doc)},apply(n){return n.selection}}),new Ii("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ii("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ql{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ob.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ii(r.key,r.spec.state,r))})}}class Ur{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let l=0;l<this.config.plugins.length;l++){let c=this.config.plugins[l];if(c.spec.appendTransaction){let u=i?i[l].n:0,d=i?i[l].state:this,h=u<t.length&&c.spec.appendTransaction.call(c,u?t.slice(u):t,d,r);if(h&&r.filterTransaction(h,l)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let p=0;p<this.config.plugins.length;p++)i.push(p<l?{state:r,n:t.length}:{state:this,n:0})}t.push(h),r=r.applyInner(h),s=!0}i&&(i[l]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ur(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Tb(this)}static create(e){let t=new ql(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ur(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new ql(this.schema,e.plugins),r=t.fields,i=new Ur(t);for(let s=0;s<r.length;s++){let l=r[s].name;i[l]=this.hasOwnProperty(l)?this[l]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ql(e.schema,e.plugins),s=new Ur(i);return i.fields.forEach(l=>{if(l.name=="doc")s.doc=Pn.fromJSON(e.schema,t.doc);else if(l.name=="selection")s.selection=oe.fromJSON(s.doc,t.selection);else if(l.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],d=u.spec.state;if(u.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,c)){s[l.name]=d.fromJSON.call(u,e,t[c],s);return}}s[l.name]=l.init(e,s)}}),s}}function Od(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Od(i,e,{})),t[r]=i}return t}class mt{constructor(e){this.spec=e,this.props={},e.props&&Od(e.props,this,this.props),this.key=e.key?e.key.key:Ad("plugin")}getState(e){return e[this.key]}}const Jl=Object.create(null);function Ad(n){return n in Jl?n+"$"+ ++Jl[n]:(Jl[n]=0,n+"$")}class sn{constructor(e="key"){this.key=Ad(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ye=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Kr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Gl=null;const yn=function(n,e,t){let r=Gl||(Gl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ab=function(){Gl=null},dr=function(n,e,t,r){return t&&(Cd(n,e,t,r,-1)||Cd(n,e,t,r,1))},Cb=/^(img|br|input|textarea|hr)$/i;function Cd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Pt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Pi(n)||Cb.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ye(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Pt(n):0}else return!1}}function Pt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mb(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Pt(n)}else if(n.parentNode&&!Pi(n))e=Ye(n),n=n.parentNode;else return null}}function Nb(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Pi(n))e=Ye(n)+1,n=n.parentNode;else return null}}function Ib(n,e,t){for(let r=e==0,i=e==Pt(n);r||i;){if(n==t)return!0;let s=Ye(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Pt(n)}}function Pi(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fs=function(n){return n.focusNode&&dr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function hr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Pb(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Rb(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Pt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Pt(r.startContainer),r.startOffset)}}}const on=typeof navigator<"u"?navigator:null,Md=typeof document<"u"?document:null,Fn=on&&on.userAgent||"",Yl=/Edge\/(\d+)/.exec(Fn),Nd=/MSIE \d/.exec(Fn),Ql=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fn),gt=!!(Nd||Ql||Yl),zn=Nd?document.documentMode:Ql?+Ql[1]:Yl?+Yl[1]:0,qt=!gt&&/gecko\/(\d+)/i.test(Fn);qt&&+(/Firefox\/(\d+)/.exec(Fn)||[0,0])[1];const Xl=!gt&&/Chrome\/(\d+)/.exec(Fn),nt=!!Xl,Id=Xl?+Xl[1]:0,at=!gt&&!!on&&/Apple Computer/.test(on.vendor),jr=at&&(/Mobile\/\w+/.test(Fn)||!!on&&on.maxTouchPoints>2),Rt=jr||(on?/Mac/.test(on.platform):!1),Db=on?/Win/.test(on.platform):!1,_n=/Android \d/.test(Fn),Ri=!!Md&&"webkitFontSmoothing"in Md.documentElement.style,Lb=Ri?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Bb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function bn(n,e){return typeof n=="number"?n:n[e]}function Fb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Pd(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let l=t||n.dom;l;){if(l.nodeType!=1){l=Kr(l);continue}let c=l,u=c==s.body,d=u?Bb(s):Fb(c),h=0,p=0;if(e.top<d.top+bn(r,"top")?p=-(d.top-e.top+bn(i,"top")):e.bottom>d.bottom-bn(r,"bottom")&&(p=e.bottom-e.top>d.bottom-d.top?e.top+bn(i,"top")-d.top:e.bottom-d.bottom+bn(i,"bottom")),e.left<d.left+bn(r,"left")?h=-(d.left-e.left+bn(i,"left")):e.right>d.right-bn(r,"right")&&(h=e.right-d.right+bn(i,"right")),h||p)if(u)s.defaultView.scrollBy(h,p);else{let g=c.scrollLeft,_=c.scrollTop;p&&(c.scrollTop+=p),h&&(c.scrollLeft+=h);let S=c.scrollLeft-g,k=c.scrollTop-_;e={left:e.left-S,top:e.top-k,right:e.right-S,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:Kr(l)}}function zb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,l=t+1;l<Math.min(innerHeight,e.bottom);l+=5){let c=n.root.elementFromPoint(s,l);if(!c||c==n.dom||!n.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=t-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:Rd(n.dom)}}function Rd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Kr(r));return e}function Wb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Dd(t,r==0?0:r-e)}function Dd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let qr=null;function $b(n){if(n.setActive)return n.setActive();if(qr)return n.focus(qr);let e=Rd(n);n.focus(qr==null?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),qr||(qr=!1,Dd(e,0))}function Ld(n,e){let t,r=2e8,i,s=0,l=e.top,c=e.top,u,d;for(let h=n.firstChild,p=0;h;h=h.nextSibling,p++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=yn(h).getClientRects();else continue;for(let g=0;g<y.length;g++){let _=y[g];if(_.top<=l&&_.bottom>=c){l=Math.max(_.bottom,l),c=Math.min(_.top,c);let S=_.left>e.left?_.left-e.left:_.right<e.left?e.left-_.right:0;if(S<r){t=h,r=S,i=S&&t.nodeType==3?{left:_.right<e.left?_.right:_.left,top:e.top}:e,h.nodeType==1&&S&&(s=p+(e.left>=(_.left+_.right)/2?1:0));continue}}else _.top>e.top&&!u&&_.left<=e.left&&_.right>=e.left&&(u=h,d={left:Math.max(_.left,Math.min(_.right,e.left)),top:_.top});!t&&(e.left>=_.right&&e.top>=_.top||e.left>=_.left&&e.top>=_.bottom)&&(s=p+1)}}return!t&&u&&(t=u,i=d,r=0),t&&t.nodeType==3?Vb(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Ld(t,i)}function Vb(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Wn(r,1);if(s.top!=s.bottom&&Zl(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Zl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Hb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Ub(n,e,t){let{node:r,offset:i}=Ld(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();s=l.left!=l.right&&t.left>(l.left+l.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Kb(n,e,t,r){let i=-1;for(let s=e,l=!1;s!=n.dom;){let c=n.docView.nearestDesc(s,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&(!l&&u.left>r.left||u.top>r.top?i=c.posBefore:(!l&&u.right<r.left||u.bottom<r.top)&&(i=c.posAfter),l=!0),!c.contentDOM&&i<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;s=c.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Bd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let l=n.childNodes[s];if(l.nodeType==1){let c=l.getClientRects();for(let u=0;u<c.length;u++){let d=c[u];if(Zl(e,d))return Bd(l,e,d)}}if((s=(s+1)%r)==i)break}return n}function jb(n,e){let t=n.dom.ownerDocument,r,i=0,s=Rb(t,e.left,e.top);s&&({node:r,offset:i}=s);let l=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),c;if(!l||!n.dom.contains(l.nodeType!=1?l.parentNode:l)){let d=n.dom.getBoundingClientRect();if(!Zl(e,d)||(l=Bd(n.dom,e,d),!l))return null}if(at)for(let d=l;r&&d;d=Kr(d))d.draggable&&(r=void 0);if(l=Hb(l,e),r){if(qt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],p;h.nodeName=="IMG"&&(p=h.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}let d;Ri&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=Kb(n,r,i,e))}c==null&&(c=Ub(n,l,e));let u=n.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function Fd(n){return n.top<n.bottom||n.left<n.right}function Wn(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Fd(r))return r}return Array.prototype.find.call(t,Fd)||n.getBoundingClientRect()}const qb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zd(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),l=Ri||qt;if(r.nodeType==3)if(l&&(qb.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let u=Wn(yn(r,i,i),t);if(qt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=Wn(yn(r,i-1,i-1),-1);if(d.top==u.top){let h=Wn(yn(r,i,i+1),-1);if(h.top!=u.top)return Di(h,h.left<d.left)}}return u}else{let u=i,d=i,h=t<0?1:-1;return t<0&&!i?(d++,h=-1):t>=0&&i==r.nodeValue.length?(u--,h=1):t<0?u--:d++,Di(Wn(yn(r,u,d),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Pt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return ea(u.getBoundingClientRect(),!1)}if(s==null&&i<Pt(r)){let u=r.childNodes[i];if(u.nodeType==1)return ea(u.getBoundingClientRect(),!0)}return ea(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Pt(r))){let u=r.childNodes[i-1],d=u.nodeType==3?yn(u,Pt(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(d)return Di(Wn(d,1),!1)}if(s==null&&i<Pt(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let d=u?u.nodeType==3?yn(u,0,l?0:1):u.nodeType==1?u:null:null;if(d)return Di(Wn(d,-1),!0)}return Di(Wn(r.nodeType==3?yn(r):r,-t),t>=0)}function Di(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ea(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Wd(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Jb(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Wd(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let c=n.docView.nearestDesc(s,!0);if(!c)break;if(c.node.isBlock){s=c.contentDOM||c.dom;break}s=c.dom.parentNode}let l=zd(n,i.pos,1);for(let c=s.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=yn(c,0,c.nodeValue.length).getClientRects();else continue;for(let d=0;d<u.length;d++){let h=u[d];if(h.bottom>h.top+1&&(t=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const Gb=/[\u0590-\u08ac]/;function Yb(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,l=i==r.parent.content.size,c=n.domSelection();return c?!Gb.test(r.parent.textContent)||!c.modify?t=="left"||t=="backward"?s:l:Wd(n,e,()=>{let{focusNode:u,focusOffset:d,anchorNode:h,anchorOffset:p}=n.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",t,"character");let g=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:_,focusOffset:S}=n.domSelectionRange(),k=_&&!g.contains(_.nodeType==1?_:_.parentNode)||u==_&&d==S;try{c.collapse(h,p),u&&(u!=h||d!=p)&&c.extend&&c.extend(u,d)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let $d=null,Vd=null,Hd=!1;function Qb(n,e,t){return $d==e&&Vd==t?Hd:($d=e,Vd=t,Hd=t=="up"||t=="down"?Jb(n,e,t):Yb(n,e,t))}const Dt=0,Ud=1,pr=2,ln=3;class Li{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Dt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,l;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(l)+l.size:this.posAtStart}else{let s,l;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(l):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Ye(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),l;if(s&&(!t||s.node))if(r&&(l=s.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let l=0;l<i.children.length;l++){let c=i.children[l];if(c.size){i=c;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let l=this.children[r],c=s+l.size;if(c>e||l instanceof qd){i=e-s;break}s=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Kd&&s.side>=0;r--);if(t<=0){let s,l=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,l=!1);return s&&t&&l&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ye(s.dom)+1:0}}else{let s,l=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,l=!1);return s&&l&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ye(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let l=r,c=0;;c++){let u=this.children[c],d=l+u.size;if(i==-1&&e<=d){let h=l+u.border;if(e>=h&&t<=d-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,h);e=l;for(let p=c;p>0;p--){let y=this.children[p-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=Ye(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||c==this.children.length-1)){t=d;for(let h=c+1;h<this.children.length;h++){let p=this.children[h];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){s=Ye(p.dom);break}t+=p.size}s==-1&&(s=this.contentDOM.childNodes.length);break}l=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),l=Math.max(e,t);for(let g=0,_=0;g<this.children.length;g++){let S=this.children[g],k=_+S.size;if(s>_&&l<k)return S.setSelection(e-_-S.border,t-_-S.border,r,i);_=k}let c=this.domFromPos(e,e?-1:1),u=t==e?c:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),h=r.domSelectionRange(),p=!1;if((qt||at)&&e==t){let{node:g,offset:_}=c;if(g.nodeType==3){if(p=!!(_&&g.nodeValue[_-1]==`
171
- `),p&&_==g.nodeValue.length)for(let S=g,k;S;S=S.parentNode){if(k=S.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:Ye(k)+1});break}let A=S.pmViewDesc;if(A&&A.node&&A.node.isBlock)break}}else{let S=g.childNodes[_-1];p=S&&(S.nodeName=="BR"||S.contentEditable=="false")}}if(qt&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let g=h.focusNode.childNodes[h.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||p&&at)&&dr(c.node,c.offset,h.anchorNode,h.anchorOffset)&&dr(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((d.extend||e==t)&&!p){d.collapse(c.node,c.offset);try{e!=t&&d.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>t){let _=c;c=u,u=_}let g=document.createRange();g.setEnd(u.node,u.offset),g.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(g)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],l=r+s.size;if(r==l?e<=l&&t>=r:e<l&&t>r){let c=r+s.border,u=l-s.border;if(e>=c&&t<=u){this.dirty=e==r||t==l?pr:Ud,e==c&&t==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ln:s.markDirty(e-c,t-c);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?pr:ln}r=l}this.dirty=pr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?pr:Ud;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Kd extends Li{constructor(e,t,r,i){let s,l=t.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(l.nodeType!=1){let c=document.createElement("span");c.appendChild(l),l=c}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Dt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Xb extends Li{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class mr extends Li{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],l=s&&s(t,i,r);return(!l||!l.dom)&&(l=fr.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new mr(e,t,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&ln||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ln&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Dt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Dt}}slice(e,t,r){let i=mr.create(this.parent,this.mark,!0,r),s=this.children,l=this.size;t<l&&(s=na(s,t,l,r)),e>0&&(s=na(s,0,e,r));for(let c=0;c<s.length;c++)s[c].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class $n extends Li{constructor(e,t,r,i,s,l,c,u,d){super(e,[],s,l),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=c}static create(e,t,r,i,s,l){let c=s.nodeViews[t.type.name],u,d=c&&c(t,s,()=>{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:p}=fr.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=Yd(h,r,t),d?u=new Zb(e,t,r,i,h,p||null,y,d,s,l+1):t.isText?new zs(e,t,r,i,h,y,s):new $n(e,t,r,i,h,p||null,y,s,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>D.empty)}return e}matchesNode(e,t,r){return this.dirty==Dt&&e.eq(this.node)&&Ws(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,l=s&&s.pos>-1?s:null,c=s&&s.pos<0,u=new tv(this,l&&l.node,e);iv(this.node,this.innerDeco,(d,h,p)=>{d.spec.marks?u.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!p&&u.syncToMarks(h==this.node.childCount?we.none:this.node.child(h).marks,r,e),u.placeWidget(d,e,i)},(d,h,p,y)=>{u.syncToMarks(d.marks,r,e);let g;u.findNodeMatch(d,h,p,y)||c&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(g=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(d,h,p,g,e)||u.updateNextNode(d,h,p,e,y,i)||u.addNode(d,h,p,e,i),i+=d.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==pr)&&(l&&this.protectLocalComposition(e,l),Jd(this.contentDOM,this.children,e),jr&&sv(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,c=ov(this.node.content,l,r-t,i-t);return c<0?null:{node:s,pos:c,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let l=new Xb(this,s,t,i);e.input.compositionNodes.push(l),this.children=na(this.children,r,r+i.length,e,l)}update(e,t,r,i){return this.dirty==ln||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Dt}updateOuterDeco(e){if(Ws(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gd(this.dom,this.nodeDOM,ta(this.outerDeco,this.node,t),ta(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function jd(n,e,t,r,i){Yd(r,e,n);let s=new $n(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class zs extends $n{constructor(e,t,r,i,s,l,c){super(e,t,r,i,s,null,l,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ln||this.dirty!=Dt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Dt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Dt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new zs(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ln)}get domAtom(){return!1}isText(e){return this.node.text==e}}class qd extends Li{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Dt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Zb extends $n{constructor(e,t,r,i,s,l,c,u,d,h){super(e,t,r,i,s,l,c,d,h),this.spec=u}update(e,t,r,i){if(this.dirty==ln)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Jd(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let l=e[s],c=l.dom;if(c.parentNode==n){for(;c!=r;)r=Qd(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(c,r);if(l instanceof mr){let u=r?r.previousSibling:n.lastChild;Jd(l.contentDOM,l.children,t),r=u?u.nextSibling:n.firstChild}}for(;r;)r=Qd(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Bi=function(n){n&&(this.nodeName=n)};Bi.prototype=Object.create(null);const gr=[new Bi];function ta(n,e,t){if(n.length==0)return gr;let r=t?gr[0]:new Bi,i=[r];for(let s=0;s<n.length;s++){let l=n[s].type.attrs;if(l){l.nodeName&&i.push(r=new Bi(l.nodeName));for(let c in l){let u=l[c];u!=null&&(t&&i.length==1&&i.push(r=new Bi(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return i}function Gd(n,e,t,r){if(t==gr&&r==gr)return e;let i=e;for(let s=0;s<r.length;s++){let l=r[s],c=t[s];if(s){let u;c&&c.nodeName==l.nodeName&&i!=n&&(u=i.parentNode)&&u.nodeName.toLowerCase()==l.nodeName||(u=document.createElement(l.nodeName),u.pmIsDeco=!0,u.appendChild(i),c=gr[0]),i=u}ev(i,c||gr[0],l)}return i}function ev(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Yd(n,e,t){return Gd(n,n,gr,ta(e,t,n.nodeType!=1))}function Ws(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Qd(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class tv{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nv(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Dt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let c=-1;for(let u=this.index;u<Math.min(this.index+3,this.top.children.length);u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=mr.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,t,r))s=this.top.children.indexOf(l,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let d=this.top.children[c];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){s=c;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let l=this.top.children[i];return l.dirty==ln&&l.dom==l.contentDOM&&(l.dirty=pr),l.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,l){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof $n){let d=this.preMatch.matched.get(u);if(d!=null&&d!=s)return!1;let h=u.dom,p,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=ln&&Ws(t,u.outerDeco));if(!y&&u.update(e,t,r,i))return this.destroyBetween(this.index,c),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(p=this.recreateWrapper(u,e,t,r,i,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=pr,p.updateChildren(i,l+1),p.dirty=Dt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,l){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ws(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let c=$n.create(this.top,t,r,i,s,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,t,r,i,s){let l=$n.create(this.top,e,t,r,i,s);l.contentDOM&&l.updateChildren(i,s+1),this.top.children.splice(this.index++,0,l),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Kd(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof mr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof zs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((at||nt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new qd(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function nv(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,l=[];e:for(;i>0;){let c;for(;;)if(r){let d=t.children[r-1];if(d instanceof mr)t=d,r=d.children.length;else{c=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let u=c.node;if(u){if(u!=n.child(i-1))break;--i,s.set(c,i),l.push(c)}}return{index:i,matched:s,matches:l.reverse()}}function rv(n,e){return n.type.side-e.type.side}function iv(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let d=0;d<n.childCount;d++){let h=n.child(d);r(h,i,e.forChild(s,h),d),s+=h.nodeSize}return}let l=0,c=[],u=null;for(let d=0;;){let h,p;for(;l<i.length&&i[l].to==s;){let k=i[l++];k.widget&&(h?(p||(p=[h])).push(k):h=k)}if(h)if(p){p.sort(rv);for(let k=0;k<p.length;k++)t(p[k],d,!!u)}else t(h,d,!!u);let y,g;if(u)g=-1,y=u,u=null;else if(d<n.childCount)g=d,y=n.child(d++);else break;for(let k=0;k<c.length;k++)c[k].to<=s&&c.splice(k--,1);for(;l<i.length&&i[l].from<=s&&i[l].to>s;)c.push(i[l++]);let _=s+y.nodeSize;if(y.isText){let k=_;l<i.length&&i[l].from<k&&(k=i[l].from);for(let A=0;A<c.length;A++)c[A].to<k&&(k=c[A].to);k<_&&(u=y.cut(k-s),y=y.cut(0,k-s),_=k,g=-1)}else for(;l<i.length&&i[l].to<_;)l++;let S=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,S,e.forChild(s,y),g),s=_}}function sv(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ov(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let l=n.child(i++),c=s;if(s+=l.nodeSize,!l.isText)continue;let u=l.text;for(;i<n.childCount;){let d=n.child(i++);if(s+=d.nodeSize,!d.isText)break;u+=d.text}if(s>=t){if(s>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let d=c<r?u.lastIndexOf(e,r-c-1):-1;if(d>=0&&d+e.length+c>=t)return c+d;if(t==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function na(n,e,t,r,i){let s=[];for(let l=0,c=0;l<n.length;l++){let u=n[l],d=c,h=c+=u.size;d>=t||h<=e?s.push(u):(d<e&&s.push(u.slice(0,e-d,r)),i&&(s.push(i),i=void 0),h>t&&s.push(u.slice(t-d,u.size,r)))}return s}function ra(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,l=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(l<0)return null;let c=r.resolve(l),u,d;if(Fs(t)){for(u=l;i&&!i.node;)i=i.parent;let p=i.node;if(i&&p.isAtom&&Q.isSelectable(p)&&i.parent&&!(p.isInline&&Ib(t.focusNode,t.focusOffset,i.dom))){let y=i.posBefore;d=new Q(l==y?c:r.resolve(y))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=l,y=l;for(let g=0;g<t.rangeCount;g++){let _=t.getRangeAt(g);p=Math.min(p,n.docView.posFromDOM(_.startContainer,_.startOffset,1)),y=Math.max(y,n.docView.posFromDOM(_.endContainer,_.endOffset,-1))}if(p<0)return null;[u,l]=y==n.state.selection.anchor?[y,p]:[p,y],c=r.resolve(l)}else u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!d){let p=e=="pointer"||n.state.selection.head<c.pos&&!s?1:-1;d=sa(n,h,c,p)}return d}function Xd(n){return n.editable?n.hasFocus():sh(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function vn(n,e=!1){let t=n.state.selection;if(nh(n,t),!!Xd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&nt){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&dr(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)av(n);else{let{anchor:r,head:i}=t,s,l;Zd&&!(t instanceof re)&&(t.$from.parent.inlineContent||(s=eh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=eh(n,t.to))),n.docView.setSelection(r,i,n,e),Zd&&(s&&th(s),l&&th(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lv(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zd=at||nt&&Id<63;function eh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(at&&i&&i.contentEditable=="false")return ia(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return ia(i);if(s)return ia(s)}}function ia(n){return n.contentEditable="true",at&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function th(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lv(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Xd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function av(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,Ye(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&gt&&zn<=11&&(r.disabled=!0,r.disabled=!1)}function nh(n,e){if(e instanceof Q){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(rh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else rh(n)}function rh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function sa(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function ih(n){return n.editable&&!n.hasFocus()?!1:sh(n)}function sh(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cv(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return dr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function oa(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&oe.findFrom(s,e)}function Vn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function oh(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let l=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Vn(n,new re(r.$anchor,l))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=oa(n.state,e);return i&&i instanceof Q?Vn(n,i):!1}else if(!(Rt&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!s||s.isText)return!1;let c=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(l=n.docView.descAt(c))&&!l.contentDOM?Q.isSelectable(s)?Vn(n,new Q(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ri?Vn(n,new re(n.state.doc.resolve(e<0?c:c+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Q&&r.node.isInline)return Vn(n,new re(e>0?r.$to:r.$from));{let i=oa(n.state,e);return i?Vn(n,i):!1}}}function $s(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Fi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Jr(n,e){return e<0?uv(n):fv(n)}function uv(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,l=!1;for(qt&&t.nodeType==1&&r<$s(t)&&Fi(t.childNodes[r],-1)&&(l=!0);;)if(r>0){if(t.nodeType!=1)break;{let c=t.childNodes[r-1];if(Fi(c,-1))i=t,s=--r;else if(c.nodeType==3)t=c,r=t.nodeValue.length;else break}}else{if(lh(t))break;{let c=t.previousSibling;for(;c&&Fi(c,-1);)i=t.parentNode,s=Ye(c),c=c.previousSibling;if(c)t=c,r=$s(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}l?la(n,t,r):i&&la(n,i,s)}function fv(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=$s(t),s,l;for(;;)if(r<i){if(t.nodeType!=1)break;let c=t.childNodes[r];if(Fi(c,1))s=t,l=++r;else break}else{if(lh(t))break;{let c=t.nextSibling;for(;c&&Fi(c,1);)s=c.parentNode,l=Ye(c)+1,c=c.nextSibling;if(c)t=c,r=0,i=$s(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&la(n,s,l)}function lh(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function dv(n,e){for(;n&&e==n.childNodes.length&&!Pi(n);)e=Ye(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function hv(n,e){for(;n&&!e&&!Pi(n);)e=Ye(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function la(n,e,t){if(e.nodeType!=3){let s,l;(l=dv(e,t))?(e=l,t=0):(s=hv(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fs(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&vn(n)},50)}function ah(n,e){let t=n.state.doc.resolve(e);if(!(nt||Db)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ch(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||Rt&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let l=oa(n.state,e);if(l&&l instanceof Q)return Vn(n,l)}if(!i.parent.inlineContent){let l=e<0?i:s,c=r instanceof xt?oe.near(l,e):oe.findFrom(l,e);return c?Vn(n,c):!1}return!1}function uh(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let l=n.state.tr;return e<0?l.delete(t.pos-s.nodeSize,t.pos):l.delete(t.pos,t.pos+s.nodeSize),n.dispatch(l),!0}return!1}function fh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function pv(n){if(!at||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fh(n,r,"true"),setTimeout(()=>fh(n,r,"false"),20)}return!1}function mv(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gv(n,e){let t=e.keyCode,r=mv(e);if(t==8||Rt&&t==72&&r=="c")return uh(n,-1)||Jr(n,-1);if(t==46&&!e.shiftKey||Rt&&t==68&&r=="c")return uh(n,1)||Jr(n,1);if(t==13||t==27)return!0;if(t==37||Rt&&t==66&&r=="c"){let i=t==37?ah(n,n.state.selection.from)=="ltr"?-1:1:-1;return oh(n,i,r)||Jr(n,i)}else if(t==39||Rt&&t==70&&r=="c"){let i=t==39?ah(n,n.state.selection.from)=="ltr"?1:-1:1;return oh(n,i,r)||Jr(n,i)}else{if(t==38||Rt&&t==80&&r=="c")return ch(n,-1,r)||Jr(n,-1);if(t==40||Rt&&t==78&&r=="c")return pv(n)||ch(n,1,r)||Jr(n,1);if(r==(Rt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function aa(n,e){n.someProp("transformCopied",g=>{e=g(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let g=r.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let l=n.someProp("clipboardSerializer")||fr.fromSchema(n.state.schema),c=bh(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));let d=u.firstChild,h,p=0;for(;d&&d.nodeType==1&&(h=yh[d.nodeName.toLowerCase()]);){for(let g=h.length-1;g>=0;g--){let _=c.createElement(h[g]);for(;u.firstChild;)_.appendChild(u.firstChild);u.appendChild(_),p++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${s}${p?` -${p}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,`
171
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],l=r.getPropertyValue(s);if(l)for(let c=void 0;;){let u=this.parser.matchStyle(s,l,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?t=t.filter(d=>!u.clearMark(d)):t=t.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return t}addElementByRule(e,t,r,i){let s,l;if(t.node)if(l=this.parser.schema.nodes[t.node],l.isLeaf)this.insertNode(l.create(t.attrs),r)||this.leafFallback(e,r);else{let u=this.enter(l,t.attrs||null,r,t.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[t.mark];r=r.concat(u.create(t.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r));else{let u=e;typeof t.contentElement=="string"?u=e.querySelector(t.contentElement):typeof t.contentElement=="function"?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}s&&this.sync(c)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];l!=c;l=l.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(l,t);this.findAtPoint(e,s)}findPlace(e,t){let r,i;for(let s=this.open;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!r||r.length>c.length)&&(r=c,i=l,!c.length)||l.solid)break}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=we.none;for(let l of r.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):nd(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let c=Zf(e,s,l.options);l.options&Ns&&l.content.length==0&&(c|=Ns);let u=we.none;return r=r.filter(d=>(l.type?l.type.allowsMarkType(d.type):nd(d.type,e))?(u=d.addToSet(u),!1):!0),this.nodes.push(new Is(e,t,u,i,null,c)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Oi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let d=t[c];if(d==""){if(c==t.length-1||c==0)continue;for(;u>=s;u--)if(l(c-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!h||h.name!=d&&!h.isInGroup(d))return!1;u--}}return!0};return l(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Q_(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xf.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function X_(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function td(n){let e={};for(let t in n)e[t]=n[t];return e}function nd(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],l=c=>{s.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:h}=c.edge(u);if(d==e||s.indexOf(h)<0&&l(h))return!0}};if(l(i.contentMatch))return!0}}class dr{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Ll(t).createDocumentFragment());let i=r,s=[];return e.forEach(l=>{if(s.length||l.marks.length){let c=0,u=0;for(;c<s.length&&u<l.marks.length;){let d=l.marks[u];if(!this.marks[d.type.name]){u++;continue}if(!d.eq(s[c][0])||d.type.spec.spanning===!1)break;c++,u++}for(;c<s.length;)i=s.pop()[1];for(;u<l.marks.length;){let d=l.marks[u++],h=this.serializeMark(d,l.isInline,t);h&&(s.push([d,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(l,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Ps(Ll(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ps(Ll(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ps(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new dr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=rd(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return rd(e.marks)}}function rd(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ll(n){return n.document||window.document}const id=new WeakMap;function Z_(n){let e=id.get(n);return e===void 0&&id.set(n,e=eb(n)),e}function eb(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Ps(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Z_(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=i.indexOf(" ");l>0&&(t=i.slice(0,l),i=i.slice(l+1));let c,u=t?n.createElementNS(t,i):n.createElement(i),d=e[1],h=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){h=2;for(let p in d)if(d[p]!=null){let y=p.indexOf(" ");y>0?u.setAttributeNS(p.slice(0,y),p.slice(y+1),d[p]):u.setAttribute(p,d[p])}}for(let p=h;p<e.length;p++){let y=e[p];if(y===0){if(p<e.length-1||p>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:g,contentDOM:_}=Ps(n,y,t,r);if(u.appendChild(g),_){if(c)throw new RangeError("Multiple content holes");c=_}}}return{dom:u,contentDOM:c}}const sd=65535,od=Math.pow(2,16);function tb(n,e){return n+e*od}function ld(n){return n&sd}function nb(n){return(n-(n&sd))/od}const ad=1,cd=2,Rs=4,ud=8;class Bl{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ud)>0}get deletedBefore(){return(this.delInfo&(ad|Rs))>0}get deletedAfter(){return(this.delInfo&(cd|Rs))>0}get deletedAcross(){return(this.delInfo&Rs)>0}}class kt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&kt.empty)return kt.empty}recover(e){let t=0,r=ld(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+nb(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let d=this.ranges[c+s],h=this.ranges[c+l],p=u+d;if(e<=p){let y=d?e==u?-1:e==p?1:t:t,g=u+i+(y<0?0:h);if(r)return g;let _=e==(t<0?u:p)?null:tb(c/3,e-u),S=e==u?cd:e==p?ad:Rs;return(t<0?e!=u:e!=p)&&(S|=ud),new Bl(g,S,_)}i+=h-d}return r?e+i:new Bl(e+i,0,null)}touches(e,t){let r=0,i=ld(t),s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let d=this.ranges[c+s],h=u+d;if(e<=h&&c==i*3)return!0;r+=this.ranges[c+l]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?s:0),u=l+(this.inverted?0:s),d=this.ranges[i+t],h=this.ranges[i+r];e(c,c+d,u,u+h),s+=h-d}}invert(){return new kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?kt.empty:new kt(e<0?[0,-e,0]:[0,0,e])}}kt.empty=new kt([]);class Ai{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Ai(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ai;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let l=this._maps[s],c=l.mapResult(e,t);if(c.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(c.recover);continue}}i|=c.delInfo,e=c.pos}return r?e:new Bl(e,i,null)}}const Fl=Object.create(null);class tt{getMap(){return kt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Fl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Fl)throw new RangeError("Duplicate use of step JSON ID "+e);return Fl[e]=t,t.prototype.jsonID=e,t}}class De{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new De(e,null)}static fail(e){return new De(null,e)}static fromReplace(e,t,r,i){try{return De.ok(e.replace(t,r,i))}catch(s){if(s instanceof Ts)return De.fail(s.message);throw s}}}function zl(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(zl(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return D.fromArray(r)}class Dn extends tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new H(zl(t.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,s)}invert(){return new rn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Dn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Dn(t.from,t.to,e.markFromJSON(t.mark))}}tt.jsonID("addMark",Dn);class rn extends tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new H(zl(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,r)}invert(){return new Dn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rn(t.pos,r.pos,this.mark)}merge(e){return e instanceof rn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rn(t.from,t.to,e.markFromJSON(t.mark))}}tt.jsonID("removeMark",rn);class Ln extends tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Ln(this.pos,t.marks[i]);return new Ln(this.pos,this.mark)}}return new zr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ln(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ln(t.pos,e.markFromJSON(t.mark))}}tt.jsonID("addNodeMark",Ln);class zr extends tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ln(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new zr(t.pos,e.markFromJSON(t.mark))}}tt.jsonID("removeNodeMark",zr);class $e extends tt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Wl(e,this.from,this.to)?De.fail("Structure replace would overwrite content"):De.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new kt([this.from,this.to-this.from,this.slice.size])}invert(e){return new $e(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new $e(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof $e)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $e(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $e(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $e(t.from,t.to,H.fromJSON(e,t.slice),!!t.structure)}}tt.jsonID("replace",$e);class Ve extends tt{constructor(e,t,r,i,s,l,c=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=l,this.structure=c}apply(e){if(this.structure&&(Wl(e,this.from,this.gapFrom)||Wl(e,this.gapTo,this.to)))return De.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return De.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?De.fromReplace(e,this.from,this.to,r):De.fail("Content does not fit in gap")}getMap(){return new kt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ve(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ve(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ve(t.from,t.to,t.gapFrom,t.gapTo,H.fromJSON(e,t.slice),t.insert,!!t.structure)}}tt.jsonID("replaceAround",Ve);function Wl(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let l=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function rb(n,e,t,r){let i=[],s=[],l,c;n.doc.nodesBetween(e,t,(u,d,h)=>{if(!u.isInline)return;let p=u.marks;if(!r.isInSet(p)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),g=Math.min(d+u.nodeSize,t),_=r.addToSet(p);for(let S=0;S<p.length;S++)p[S].isInSet(_)||(l&&l.to==y&&l.mark.eq(p[S])?l.to=g:i.push(l=new rn(y,g,p[S])));c&&c.to==y?c.to=g:s.push(c=new Dn(y,g,r))}}),i.forEach(u=>n.step(u)),s.forEach(u=>n.step(u))}function ib(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(l,c)=>{if(!l.isInline)return;s++;let u=null;if(r instanceof Ms){let d=l.marks,h;for(;h=r.isInSet(d);)(u||(u=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let d=Math.min(c+l.nodeSize,t);for(let h=0;h<u.length;h++){let p=u[h],y;for(let g=0;g<i.length;g++){let _=i[g];_.step==s-1&&p.eq(i[g].style)&&(y=_)}y?(y.to=d,y.step=s):i.push({style:p,from:Math.max(c,e),to:d,step:s})}}}),i.forEach(l=>n.step(new rn(l.from,l.to,l.style)))}function $l(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),l=[],c=e+1;for(let u=0;u<s.childCount;u++){let d=s.child(u),h=c+d.nodeSize,p=r.matchType(d.type);if(!p)l.push(new $e(c,h,H.empty));else{r=p;for(let y=0;y<d.marks.length;y++)t.allowsMarkType(d.marks[y].type)||n.step(new rn(c,h,d.marks[y]));if(i&&d.isText&&t.whitespace!="pre"){let y,g=/\r?\n|\r/g,_;for(;y=g.exec(d.text);)_||(_=new H(D.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),l.push(new $e(c+y.index,c+y.index+y[0].length,_))}}c=h}if(!r.validEnd){let u=r.fillBefore(D.empty,!0);n.replace(c,c,new H(u,0,0))}for(let u=l.length-1;u>=0;u--)n.step(l[u])}function sb(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Wr(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),l=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,l,t))return r;if(r==0||i.type.spec.isolating||!sb(i,s,l))break}return null}function ob(n,e,t){let{$from:r,$to:i,depth:s}=e,l=r.before(s+1),c=i.after(s+1),u=l,d=c,h=D.empty,p=0;for(let _=s,S=!1;_>t;_--)S||r.index(_)>0?(S=!0,h=D.from(r.node(_).copy(h)),p++):u--;let y=D.empty,g=0;for(let _=s,S=!1;_>t;_--)S||i.after(_+1)<i.end(_)?(S=!0,y=D.from(i.node(_).copy(y)),g++):d++;n.step(new Ve(u,d,l,c,new H(h.append(y),p,g),h.size-p,!0))}function Vl(n,e,t=null,r=n){let i=lb(n,e),s=i&&ab(r,e);return s?i.map(fd).concat({type:e,attrs:t}).concat(s.map(fd)):null}function fd(n){return{type:n,attrs:null}}function lb(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return t.canReplaceWith(r,i,l)?s:null}function ab(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),l=e.contentMatch.findWrapping(s.type);if(!l)return null;let u=(l.length?l[l.length-1]:e).contentMatch;for(let d=r;u&&d<i;d++)u=u.matchType(t.child(d).type);return!u||!u.validEnd?null:l}function cb(n,e,t){let r=D.empty;for(let l=t.length-1;l>=0;l--){if(r.size){let c=t[l].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=D.from(t[l].type.create(t[l].attrs,r))}let i=e.start,s=e.end;n.step(new Ve(i,s,i,s,new H(r,0,0),t.length,!0))}function ub(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(l,c)=>{let u=typeof i=="function"?i(l):i;if(l.isTextblock&&!l.hasMarkup(r,u)&&fb(n.doc,n.mapping.slice(s).map(c),r)){let d=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",_=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!_?d=!1:!g&&_&&(d=!0)}d===!1&&hd(n,l,c,s),$l(n,n.mapping.slice(s).map(c,1),r,void 0,d===null);let h=n.mapping.slice(s),p=h.map(c,1),y=h.map(c+l.nodeSize,1);return n.step(new Ve(p,y,p+1,y-1,new H(D.from(r.create(u,null,l.marks)),0,0),1,!0)),d===!0&&dd(n,l,c,s),!1}})}function dd(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(i.text);){let u=n.mapping.slice(r).map(t+1+s+l.index);n.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function hd(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let l=n.mapping.slice(r).map(t+1+s);n.replaceWith(l,l+1,e.type.schema.text(`
172
+ `))}})}function fb(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function db(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let l=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,l);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ve(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new H(D.from(l),0,0),1,!0))}function gn(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,l=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>s;d--,h--){let p=i.node(d),y=i.index(d);if(p.type.spec.isolating)return!1;let g=p.content.cutByIndex(y,p.childCount),_=r&&r[h+1];_&&(g=g.replaceChild(0,_.type.create(_.attrs)));let S=r&&r[h]||p;if(!p.canReplace(y+1,p.childCount)||!S.type.validContent(g))return!1}let c=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(c,c,u?u.type:i.node(s+1).type)}function hb(n,e,t=1,r){let i=n.doc.resolve(e),s=D.empty,l=D.empty;for(let c=i.depth,u=i.depth-t,d=t-1;c>u;c--,d--){s=D.from(i.node(c).copy(s));let h=r&&r[d];l=D.from(h?h.type.create(h.attrs,l):i.node(c).copy(l))}n.step(new $e(e,e,new H(s.append(l),t,t),!0))}function Bn(n,e){let t=n.resolve(e),r=t.index();return pd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function pb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),l=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(l),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function pd(n,e){return!!(n&&e&&!n.isLeaf&&pb(n,e))}function Ds(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,l,c=r.index(i);if(i==r.depth?(s=r.nodeBefore,l=r.nodeAfter):t>0?(s=r.node(i+1),c++,l=r.node(i).maybeChild(c)):(s=r.node(i).maybeChild(c-1),l=r.node(i+1)),s&&!s.isTextblock&&pd(s,l)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function mb(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),l=s.node().type;if(i&&l.inlineContent){let h=l.whitespace=="pre",p=!!l.contentMatch.matchType(i);h&&!p?r=!1:!h&&p&&(r=!0)}let c=n.steps.length;if(r===!1){let h=n.doc.resolve(e+t);hd(n,h.node(),h.before(),c)}l.inlineContent&&$l(n,e+t-1,l,s.node().contentMatchAt(s.index()),r==null);let u=n.mapping.slice(c),d=u.map(e-t);if(n.step(new $e(d,u.map(e+t,-1),H.empty,!0)),r===!0){let h=n.doc.resolve(d);dd(n,h.node(),h.before(),n.steps.length)}return n}function gb(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function md(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let l=r.depth;l>=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(c>0?1:0),d=r.node(l),h=!1;if(s==1)h=d.canReplace(u,u,i);else{let p=d.contentMatchAt(u).findWrapping(i.firstChild.type);h=p&&d.canReplaceWith(u,u,p[0])}if(h)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Ls(n,e,t=e,r=H.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return gd(i,s,r)?new $e(e,t,r):new yb(i,s,r).fit()}function gd(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class yb{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=D.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=D.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,l=r.depth,c=i.depth;for(;l&&c&&s.childCount==1;)s=s.firstChild.content,l--,c--;let u=new H(s,l,c);return e>-1?new Ve(r.pos,e,this.$to.pos,this.$to.end(),u,t):u.size||r.pos!=this.$to.pos?new $e(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Hl(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let l=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:d}=this.frontier[c],h,p=null;if(t==1&&(l?d.matchType(l.type)||(p=d.fillBefore(D.from(l),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:c,parent:s,inject:p};if(t==2&&l&&(h=d.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:s,wrap:h};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Hl(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new H(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Hl(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new H(Ci(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new H(Ci(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let S=0;S<s.length;S++)this.openFrontierNode(s[S]);let l=this.unplaced,c=r?r.content:l.content,u=l.openStart-e,d=0,h=[],{match:p,type:y}=this.frontier[t];if(i){for(let S=0;S<i.childCount;S++)h.push(i.child(S));p=p.matchFragment(i)}let g=c.size+e-(l.content.size-l.openEnd);for(;d<c.childCount;){let S=c.child(d),k=p.matchType(S.type);if(!k)break;d++,(d>1||u==0||S.content.size)&&(p=k,h.push(yd(S.mark(y.allowedMarks(S.marks)),d==1?u:0,d==c.childCount?g:-1)))}let _=d==c.childCount;_||(g=-1),this.placed=Mi(this.placed,t,D.from(h)),this.frontier[t].match=p,_&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let S=0,k=c;S<g;S++){let A=k.lastChild;this.frontier.push({type:A.type,match:A.contentMatchAt(A.childCount)}),k=A.content}this.unplaced=_?e==0?H.empty:new H(Ci(l.content,e-1,1),e-1,g<0?l.openEnd:e-1):new H(Ci(l.content,e,d),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ul(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),l=Ul(e,t,i,r,s);if(l){for(let c=t-1;c>=0;c--){let{match:u,type:d}=this.frontier[c],h=Ul(e,c,d,u,!0);if(!h||h.childCount)continue e}return{depth:t,fit:l,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Mi(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mi(this.placed,this.depth,D.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(D.empty,!0);t.childCount&&(this.placed=Mi(this.placed,this.frontier.length,t))}}function Ci(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ci(n.firstChild.content,e-1,t)))}function Mi(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Mi(n.lastChild.content,e-1,t)))}function Hl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function yd(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,yd(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(D.empty,!0)))),n.copy(r)}function Ul(n,e,t,r,i){let s=n.node(e),l=i?n.indexAfter(e):n.index(e);if(l==s.childCount&&!t.compatibleContent(s.type))return null;let c=r.fillBefore(s.content,!0,l);return c&&!_b(t,s.content,l)?c:null}function _b(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function bb(n){return n.spec.defining||n.spec.definingForContent}function vb(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(gd(i,s,r))return n.step(new $e(e,t,r));let l=bd(i,n.doc.resolve(t));l[l.length-1]==0&&l.pop();let c=-(i.depth+1);l.unshift(c);for(let y=i.depth,g=i.pos-1;y>0;y--,g--){let _=i.node(y).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(y)>-1?c=y:i.before(y)==g&&l.splice(1,0,-y)}let u=l.indexOf(c),d=[],h=r.openStart;for(let y=r.content,g=0;;g++){let _=y.firstChild;if(d.push(_),g==r.openStart)break;y=_.content}for(let y=h-1;y>=0;y--){let g=d[y],_=bb(g.type);if(_&&!g.sameMarkup(i.node(Math.abs(c)-1)))h=y;else if(_||!g.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let g=(y+h+1)%(r.openStart+1),_=d[g];if(_)for(let S=0;S<l.length;S++){let k=l[(S+u)%l.length],A=!0;k<0&&(A=!1,k=-k);let P=i.node(k-1),L=i.index(k-1);if(P.canReplaceWith(L,L,_.type,_.marks))return n.replace(i.before(k),A?s.after(k):t,new H(_d(r.content,0,r.openStart,g),g,r.openEnd))}}let p=n.steps.length;for(let y=l.length-1;y>=0&&(n.replace(e,t,r),!(n.steps.length>p));y--){let g=l[y];g<0||(e=i.before(g),t=s.after(g))}}function _d(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(_d(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),l=s.fillBefore(n).append(n);n=l.append(s.matchFragment(l).fillBefore(D.empty,!0))}return n}function wb(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=gb(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new H(D.from(r),0,0))}function Sb(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=bd(r,i);for(let l=0;l<s.length;l++){let c=s[l],u=l==s.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return n.delete(r.start(c),i.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return n.delete(r.before(c),i.after(c))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&t>r.end(l)&&i.end(l)-t!=i.depth-l&&r.start(l-1)==i.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),i.index(l-1)))return n.delete(r.before(l),t);n.delete(e,t)}function bd(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class $r extends tt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return De.fromReplace(e,this.pos,this.pos+1,new H(D.from(i),0,t.isLeaf?0:1))}getMap(){return kt.empty}invert(e){return new $r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new $r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new $r(t.pos,t.attr,t.value)}}tt.jsonID("attr",$r);class Ni extends tt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return De.ok(r)}getMap(){return kt.empty}invert(e){return new Ni(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ni(t.attr,t.value)}}tt.jsonID("docAttr",Ni);let Vr=class extends Error{};Vr=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Vr.prototype=Object.create(Error.prototype),Vr.prototype.constructor=Vr,Vr.prototype.name="TransformError";class kb{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ai}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Vr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=H.empty){let i=Ls(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new H(D.from(r),0,0))}delete(e,t){return this.replace(e,t,H.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return vb(this,e,t,r),this}replaceRangeWith(e,t,r){return wb(this,e,t,r),this}deleteRange(e,t){return Sb(this,e,t),this}lift(e,t){return ob(this,e,t),this}join(e,t=1){return mb(this,e,t),this}wrap(e,t){return cb(this,e,t),this}setBlockType(e,t=e,r,i=null){return ub(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return db(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new $r(e,t,r)),this}setDocAttribute(e,t){return this.step(new Ni(e,t)),this}addNodeMark(e,t){return this.step(new Ln(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new zr(e,t)),this}split(e,t=1,r){return hb(this,e,t,r),this}addMark(e,t,r){return rb(this,e,t,r),this}removeMark(e,t,r){return ib(this,e,t,r),this}clearIncompatible(e,t,r){return $l(this,e,t,r),this}}const Kl=Object.create(null);class oe{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new xb(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=H.empty){let r=t.content.lastChild,i=null;for(let c=0;c<t.openEnd;c++)i=r,r=r.lastChild;let s=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],h=e.mapping.slice(s);e.replaceRange(h.map(u.pos),h.map(d.pos),c?H.empty:t),c==0&&Sd(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:c}=i[s],u=e.mapping.slice(r),d=u.map(l.pos),h=u.map(c.pos);s?e.deleteRange(d,h):(e.replaceRangeWith(d,h,t),Sd(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new re(e):Hr(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let l=t<0?Hr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Hr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new xt(e.node(0))}static atStart(e){return Hr(e,e,0,0,1)||new xt(e)}static atEnd(e){return Hr(e,e,e.content.size,e.childCount,-1)||new xt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kl[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class xb{constructor(e,t){this.$from=e,this.$to=t}}let vd=!1;function wd(n){!vd&&!n.parent.inlineContent&&(vd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends oe{constructor(e,t=e){wd(e),wd(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return oe.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=H.empty){if(super.replace(e,t),t==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=oe.findFrom(t,r,!0)||oe.findFrom(t,-r,!0);if(s)t=s.$head;else return oe.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(oe.findFrom(e,-r,!0)||oe.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new re(e,t)}}oe.jsonID("text",re);class Bs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Bs(e.map(this.anchor),e.map(this.head))}resolve(e){return re.between(e.resolve(this.anchor),e.resolve(this.head))}}class Q extends oe{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?oe.near(s):new Q(s)}content(){return new H(D.from(this.node),0,0)}eq(e){return e instanceof Q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new jl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Q(e.resolve(t.anchor))}static create(e,t){return new Q(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Q.prototype.visible=!1,oe.jsonID("node",Q);class jl{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Bs(r,r):new jl(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Q.isSelectable(r)?new Q(t):oe.near(t)}}class xt extends oe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=H.empty){if(t==H.empty){e.delete(0,e.doc.content.size);let r=oe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new xt(e)}map(e){return new xt(e)}eq(e){return e instanceof xt}getBookmark(){return Eb}}oe.jsonID("all",xt);const Eb={map(){return this},resolve(n){return new xt(n)}};function Hr(n,e,t,r,i,s=!1){if(e.inlineContent)return re.create(n,t);for(let l=r-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let c=e.child(l);if(c.isAtom){if(!s&&Q.isSelectable(c))return Q.create(n,t-(i<0?c.nodeSize:0))}else{let u=Hr(n,c,t+i,i<0?c.childCount:0,i,s);if(u)return u}t+=c.nodeSize*i}return null}function Sd(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof $e||i instanceof Ve))return;let s=n.mapping.maps[r],l;s.forEach((c,u,d,h)=>{l==null&&(l=h)}),n.setSelection(oe.near(n.doc.resolve(l),t))}const kd=1,xd=2,Ed=4;class Tb extends kb{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|kd)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&kd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=xd,this}ensureMarks(e){return we.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&xd)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let l=this.doc.resolve(t);s=r==t?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(oe.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ed,this}get scrolledIntoView(){return(this.updated&Ed)>0}}function Td(n,e){return!e||!n?n:n.bind(e)}class Ii{constructor(e,t,r){this.name=e,this.init=Td(t.init,r),this.apply=Td(t.apply,r)}}const Ob=[new Ii("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ii("selection",{init(n,e){return n.selection||oe.atStart(e.doc)},apply(n){return n.selection}}),new Ii("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ii("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ql{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ob.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ii(r.key,r.spec.state,r))})}}class Ur{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let l=0;l<this.config.plugins.length;l++){let c=this.config.plugins[l];if(c.spec.appendTransaction){let u=i?i[l].n:0,d=i?i[l].state:this,h=u<t.length&&c.spec.appendTransaction.call(c,u?t.slice(u):t,d,r);if(h&&r.filterTransaction(h,l)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let p=0;p<this.config.plugins.length;p++)i.push(p<l?{state:r,n:t.length}:{state:this,n:0})}t.push(h),r=r.applyInner(h),s=!0}i&&(i[l]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ur(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Tb(this)}static create(e){let t=new ql(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ur(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new ql(this.schema,e.plugins),r=t.fields,i=new Ur(t);for(let s=0;s<r.length;s++){let l=r[s].name;i[l]=this.hasOwnProperty(l)?this[l]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ql(e.schema,e.plugins),s=new Ur(i);return i.fields.forEach(l=>{if(l.name=="doc")s.doc=Pn.fromJSON(e.schema,t.doc);else if(l.name=="selection")s.selection=oe.fromJSON(s.doc,t.selection);else if(l.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],d=u.spec.state;if(u.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,c)){s[l.name]=d.fromJSON.call(u,e,t[c],s);return}}s[l.name]=l.init(e,s)}}),s}}function Od(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Od(i,e,{})),t[r]=i}return t}class mt{constructor(e){this.spec=e,this.props={},e.props&&Od(e.props,this,this.props),this.key=e.key?e.key.key:Ad("plugin")}getState(e){return e[this.key]}}const Jl=Object.create(null);function Ad(n){return n in Jl?n+"$"+ ++Jl[n]:(Jl[n]=0,n+"$")}class sn{constructor(e="key"){this.key=Ad(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ye=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Kr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Gl=null;const yn=function(n,e,t){let r=Gl||(Gl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ab=function(){Gl=null},hr=function(n,e,t,r){return t&&(Cd(n,e,t,r,-1)||Cd(n,e,t,r,1))},Cb=/^(img|br|input|textarea|hr)$/i;function Cd(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Pt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Pi(n)||Cb.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ye(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Pt(n):0}else return!1}}function Pt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mb(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Pt(n)}else if(n.parentNode&&!Pi(n))e=Ye(n),n=n.parentNode;else return null}}function Nb(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Pi(n))e=Ye(n)+1,n=n.parentNode;else return null}}function Ib(n,e,t){for(let r=e==0,i=e==Pt(n);r||i;){if(n==t)return!0;let s=Ye(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Pt(n)}}function Pi(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fs=function(n){return n.focusNode&&hr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function pr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Pb(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Rb(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Pt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Pt(r.startContainer),r.startOffset)}}}const on=typeof navigator<"u"?navigator:null,Md=typeof document<"u"?document:null,Fn=on&&on.userAgent||"",Yl=/Edge\/(\d+)/.exec(Fn),Nd=/MSIE \d/.exec(Fn),Ql=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fn),gt=!!(Nd||Ql||Yl),zn=Nd?document.documentMode:Ql?+Ql[1]:Yl?+Yl[1]:0,qt=!gt&&/gecko\/(\d+)/i.test(Fn);qt&&+(/Firefox\/(\d+)/.exec(Fn)||[0,0])[1];const Xl=!gt&&/Chrome\/(\d+)/.exec(Fn),nt=!!Xl,Id=Xl?+Xl[1]:0,at=!gt&&!!on&&/Apple Computer/.test(on.vendor),jr=at&&(/Mobile\/\w+/.test(Fn)||!!on&&on.maxTouchPoints>2),Rt=jr||(on?/Mac/.test(on.platform):!1),Db=on?/Win/.test(on.platform):!1,_n=/Android \d/.test(Fn),Ri=!!Md&&"webkitFontSmoothing"in Md.documentElement.style,Lb=Ri?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Bb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function bn(n,e){return typeof n=="number"?n:n[e]}function Fb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Pd(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let l=t||n.dom;l;){if(l.nodeType!=1){l=Kr(l);continue}let c=l,u=c==s.body,d=u?Bb(s):Fb(c),h=0,p=0;if(e.top<d.top+bn(r,"top")?p=-(d.top-e.top+bn(i,"top")):e.bottom>d.bottom-bn(r,"bottom")&&(p=e.bottom-e.top>d.bottom-d.top?e.top+bn(i,"top")-d.top:e.bottom-d.bottom+bn(i,"bottom")),e.left<d.left+bn(r,"left")?h=-(d.left-e.left+bn(i,"left")):e.right>d.right-bn(r,"right")&&(h=e.right-d.right+bn(i,"right")),h||p)if(u)s.defaultView.scrollBy(h,p);else{let g=c.scrollLeft,_=c.scrollTop;p&&(c.scrollTop+=p),h&&(c.scrollLeft+=h);let S=c.scrollLeft-g,k=c.scrollTop-_;e={left:e.left-S,top:e.top-k,right:e.right-S,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:Kr(l)}}function zb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,l=t+1;l<Math.min(innerHeight,e.bottom);l+=5){let c=n.root.elementFromPoint(s,l);if(!c||c==n.dom||!n.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=t-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:Rd(n.dom)}}function Rd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Kr(r));return e}function Wb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Dd(t,r==0?0:r-e)}function Dd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let qr=null;function $b(n){if(n.setActive)return n.setActive();if(qr)return n.focus(qr);let e=Rd(n);n.focus(qr==null?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),qr||(qr=!1,Dd(e,0))}function Ld(n,e){let t,r=2e8,i,s=0,l=e.top,c=e.top,u,d;for(let h=n.firstChild,p=0;h;h=h.nextSibling,p++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=yn(h).getClientRects();else continue;for(let g=0;g<y.length;g++){let _=y[g];if(_.top<=l&&_.bottom>=c){l=Math.max(_.bottom,l),c=Math.min(_.top,c);let S=_.left>e.left?_.left-e.left:_.right<e.left?e.left-_.right:0;if(S<r){t=h,r=S,i=S&&t.nodeType==3?{left:_.right<e.left?_.right:_.left,top:e.top}:e,h.nodeType==1&&S&&(s=p+(e.left>=(_.left+_.right)/2?1:0));continue}}else _.top>e.top&&!u&&_.left<=e.left&&_.right>=e.left&&(u=h,d={left:Math.max(_.left,Math.min(_.right,e.left)),top:_.top});!t&&(e.left>=_.right&&e.top>=_.top||e.left>=_.left&&e.top>=_.bottom)&&(s=p+1)}}return!t&&u&&(t=u,i=d,r=0),t&&t.nodeType==3?Vb(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Ld(t,i)}function Vb(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Wn(r,1);if(s.top!=s.bottom&&Zl(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Zl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Hb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Ub(n,e,t){let{node:r,offset:i}=Ld(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();s=l.left!=l.right&&t.left>(l.left+l.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Kb(n,e,t,r){let i=-1;for(let s=e,l=!1;s!=n.dom;){let c=n.docView.nearestDesc(s,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&(!l&&u.left>r.left||u.top>r.top?i=c.posBefore:(!l&&u.right<r.left||u.bottom<r.top)&&(i=c.posAfter),l=!0),!c.contentDOM&&i<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;s=c.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Bd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let l=n.childNodes[s];if(l.nodeType==1){let c=l.getClientRects();for(let u=0;u<c.length;u++){let d=c[u];if(Zl(e,d))return Bd(l,e,d)}}if((s=(s+1)%r)==i)break}return n}function jb(n,e){let t=n.dom.ownerDocument,r,i=0,s=Rb(t,e.left,e.top);s&&({node:r,offset:i}=s);let l=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),c;if(!l||!n.dom.contains(l.nodeType!=1?l.parentNode:l)){let d=n.dom.getBoundingClientRect();if(!Zl(e,d)||(l=Bd(n.dom,e,d),!l))return null}if(at)for(let d=l;r&&d;d=Kr(d))d.draggable&&(r=void 0);if(l=Hb(l,e),r){if(qt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],p;h.nodeName=="IMG"&&(p=h.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}let d;Ri&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=Kb(n,r,i,e))}c==null&&(c=Ub(n,l,e));let u=n.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function Fd(n){return n.top<n.bottom||n.left<n.right}function Wn(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Fd(r))return r}return Array.prototype.find.call(t,Fd)||n.getBoundingClientRect()}const qb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zd(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),l=Ri||qt;if(r.nodeType==3)if(l&&(qb.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let u=Wn(yn(r,i,i),t);if(qt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=Wn(yn(r,i-1,i-1),-1);if(d.top==u.top){let h=Wn(yn(r,i,i+1),-1);if(h.top!=u.top)return Di(h,h.left<d.left)}}return u}else{let u=i,d=i,h=t<0?1:-1;return t<0&&!i?(d++,h=-1):t>=0&&i==r.nodeValue.length?(u--,h=1):t<0?u--:d++,Di(Wn(yn(r,u,d),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Pt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return ea(u.getBoundingClientRect(),!1)}if(s==null&&i<Pt(r)){let u=r.childNodes[i];if(u.nodeType==1)return ea(u.getBoundingClientRect(),!0)}return ea(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Pt(r))){let u=r.childNodes[i-1],d=u.nodeType==3?yn(u,Pt(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(d)return Di(Wn(d,1),!1)}if(s==null&&i<Pt(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let d=u?u.nodeType==3?yn(u,0,l?0:1):u.nodeType==1?u:null:null;if(d)return Di(Wn(d,-1),!0)}return Di(Wn(r.nodeType==3?yn(r):r,-t),t>=0)}function Di(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ea(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Wd(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Jb(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Wd(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let c=n.docView.nearestDesc(s,!0);if(!c)break;if(c.node.isBlock){s=c.contentDOM||c.dom;break}s=c.dom.parentNode}let l=zd(n,i.pos,1);for(let c=s.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=yn(c,0,c.nodeValue.length).getClientRects();else continue;for(let d=0;d<u.length;d++){let h=u[d];if(h.bottom>h.top+1&&(t=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const Gb=/[\u0590-\u08ac]/;function Yb(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,l=i==r.parent.content.size,c=n.domSelection();return c?!Gb.test(r.parent.textContent)||!c.modify?t=="left"||t=="backward"?s:l:Wd(n,e,()=>{let{focusNode:u,focusOffset:d,anchorNode:h,anchorOffset:p}=n.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",t,"character");let g=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:_,focusOffset:S}=n.domSelectionRange(),k=_&&!g.contains(_.nodeType==1?_:_.parentNode)||u==_&&d==S;try{c.collapse(h,p),u&&(u!=h||d!=p)&&c.extend&&c.extend(u,d)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let $d=null,Vd=null,Hd=!1;function Qb(n,e,t){return $d==e&&Vd==t?Hd:($d=e,Vd=t,Hd=t=="up"||t=="down"?Jb(n,e,t):Yb(n,e,t))}const Dt=0,Ud=1,mr=2,ln=3;class Li{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Dt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,l;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(l)+l.size:this.posAtStart}else{let s,l;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(l):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Ye(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),l;if(s&&(!t||s.node))if(r&&(l=s.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let l=0;l<i.children.length;l++){let c=i.children[l];if(c.size){i=c;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let l=this.children[r],c=s+l.size;if(c>e||l instanceof qd){i=e-s;break}s=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Kd&&s.side>=0;r--);if(t<=0){let s,l=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,l=!1);return s&&t&&l&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ye(s.dom)+1:0}}else{let s,l=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,l=!1);return s&&l&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ye(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let l=r,c=0;;c++){let u=this.children[c],d=l+u.size;if(i==-1&&e<=d){let h=l+u.border;if(e>=h&&t<=d-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,h);e=l;for(let p=c;p>0;p--){let y=this.children[p-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=Ye(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||c==this.children.length-1)){t=d;for(let h=c+1;h<this.children.length;h++){let p=this.children[h];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){s=Ye(p.dom);break}t+=p.size}s==-1&&(s=this.contentDOM.childNodes.length);break}l=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),l=Math.max(e,t);for(let g=0,_=0;g<this.children.length;g++){let S=this.children[g],k=_+S.size;if(s>_&&l<k)return S.setSelection(e-_-S.border,t-_-S.border,r,i);_=k}let c=this.domFromPos(e,e?-1:1),u=t==e?c:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),h=r.domSelectionRange(),p=!1;if((qt||at)&&e==t){let{node:g,offset:_}=c;if(g.nodeType==3){if(p=!!(_&&g.nodeValue[_-1]==`
173
+ `),p&&_==g.nodeValue.length)for(let S=g,k;S;S=S.parentNode){if(k=S.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:Ye(k)+1});break}let A=S.pmViewDesc;if(A&&A.node&&A.node.isBlock)break}}else{let S=g.childNodes[_-1];p=S&&(S.nodeName=="BR"||S.contentEditable=="false")}}if(qt&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let g=h.focusNode.childNodes[h.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||p&&at)&&hr(c.node,c.offset,h.anchorNode,h.anchorOffset)&&hr(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((d.extend||e==t)&&!p){d.collapse(c.node,c.offset);try{e!=t&&d.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>t){let _=c;c=u,u=_}let g=document.createRange();g.setEnd(u.node,u.offset),g.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(g)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],l=r+s.size;if(r==l?e<=l&&t>=r:e<l&&t>r){let c=r+s.border,u=l-s.border;if(e>=c&&t<=u){this.dirty=e==r||t==l?mr:Ud,e==c&&t==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ln:s.markDirty(e-c,t-c);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?mr:ln}r=l}this.dirty=mr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?mr:Ud;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Kd extends Li{constructor(e,t,r,i){let s,l=t.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(l.nodeType!=1){let c=document.createElement("span");c.appendChild(l),l=c}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Dt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Xb extends Li{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class gr extends Li{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],l=s&&s(t,i,r);return(!l||!l.dom)&&(l=dr.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new gr(e,t,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&ln||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ln&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Dt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Dt}}slice(e,t,r){let i=gr.create(this.parent,this.mark,!0,r),s=this.children,l=this.size;t<l&&(s=na(s,t,l,r)),e>0&&(s=na(s,0,e,r));for(let c=0;c<s.length;c++)s[c].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class $n extends Li{constructor(e,t,r,i,s,l,c,u,d){super(e,[],s,l),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=c}static create(e,t,r,i,s,l){let c=s.nodeViews[t.type.name],u,d=c&&c(t,s,()=>{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:p}=dr.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=Yd(h,r,t),d?u=new Zb(e,t,r,i,h,p||null,y,d,s,l+1):t.isText?new zs(e,t,r,i,h,y,s):new $n(e,t,r,i,h,p||null,y,s,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>D.empty)}return e}matchesNode(e,t,r){return this.dirty==Dt&&e.eq(this.node)&&Ws(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,l=s&&s.pos>-1?s:null,c=s&&s.pos<0,u=new tv(this,l&&l.node,e);iv(this.node,this.innerDeco,(d,h,p)=>{d.spec.marks?u.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!p&&u.syncToMarks(h==this.node.childCount?we.none:this.node.child(h).marks,r,e),u.placeWidget(d,e,i)},(d,h,p,y)=>{u.syncToMarks(d.marks,r,e);let g;u.findNodeMatch(d,h,p,y)||c&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(g=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(d,h,p,g,e)||u.updateNextNode(d,h,p,e,y,i)||u.addNode(d,h,p,e,i),i+=d.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==mr)&&(l&&this.protectLocalComposition(e,l),Jd(this.contentDOM,this.children,e),jr&&sv(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,c=ov(this.node.content,l,r-t,i-t);return c<0?null:{node:s,pos:c,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let l=new Xb(this,s,t,i);e.input.compositionNodes.push(l),this.children=na(this.children,r,r+i.length,e,l)}update(e,t,r,i){return this.dirty==ln||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Dt}updateOuterDeco(e){if(Ws(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gd(this.dom,this.nodeDOM,ta(this.outerDeco,this.node,t),ta(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function jd(n,e,t,r,i){Yd(r,e,n);let s=new $n(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class zs extends $n{constructor(e,t,r,i,s,l,c){super(e,t,r,i,s,null,l,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ln||this.dirty!=Dt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Dt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Dt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new zs(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ln)}get domAtom(){return!1}isText(e){return this.node.text==e}}class qd extends Li{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Dt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Zb extends $n{constructor(e,t,r,i,s,l,c,u,d,h){super(e,t,r,i,s,l,c,d,h),this.spec=u}update(e,t,r,i){if(this.dirty==ln)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Jd(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let l=e[s],c=l.dom;if(c.parentNode==n){for(;c!=r;)r=Qd(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(c,r);if(l instanceof gr){let u=r?r.previousSibling:n.lastChild;Jd(l.contentDOM,l.children,t),r=u?u.nextSibling:n.firstChild}}for(;r;)r=Qd(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Bi=function(n){n&&(this.nodeName=n)};Bi.prototype=Object.create(null);const yr=[new Bi];function ta(n,e,t){if(n.length==0)return yr;let r=t?yr[0]:new Bi,i=[r];for(let s=0;s<n.length;s++){let l=n[s].type.attrs;if(l){l.nodeName&&i.push(r=new Bi(l.nodeName));for(let c in l){let u=l[c];u!=null&&(t&&i.length==1&&i.push(r=new Bi(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return i}function Gd(n,e,t,r){if(t==yr&&r==yr)return e;let i=e;for(let s=0;s<r.length;s++){let l=r[s],c=t[s];if(s){let u;c&&c.nodeName==l.nodeName&&i!=n&&(u=i.parentNode)&&u.nodeName.toLowerCase()==l.nodeName||(u=document.createElement(l.nodeName),u.pmIsDeco=!0,u.appendChild(i),c=yr[0]),i=u}ev(i,c||yr[0],l)}return i}function ev(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Yd(n,e,t){return Gd(n,n,yr,ta(e,t,n.nodeType!=1))}function Ws(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Qd(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class tv{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nv(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Dt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let c=-1;for(let u=this.index;u<Math.min(this.index+3,this.top.children.length);u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=gr.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,t,r))s=this.top.children.indexOf(l,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let d=this.top.children[c];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){s=c;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let l=this.top.children[i];return l.dirty==ln&&l.dom==l.contentDOM&&(l.dirty=mr),l.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,l){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof $n){let d=this.preMatch.matched.get(u);if(d!=null&&d!=s)return!1;let h=u.dom,p,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=ln&&Ws(t,u.outerDeco));if(!y&&u.update(e,t,r,i))return this.destroyBetween(this.index,c),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(p=this.recreateWrapper(u,e,t,r,i,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=mr,p.updateChildren(i,l+1),p.dirty=Dt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,l){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ws(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let c=$n.create(this.top,t,r,i,s,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,t,r,i,s){let l=$n.create(this.top,e,t,r,i,s);l.contentDOM&&l.updateChildren(i,s+1),this.top.children.splice(this.index++,0,l),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Kd(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof gr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof zs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((at||nt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new qd(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function nv(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,l=[];e:for(;i>0;){let c;for(;;)if(r){let d=t.children[r-1];if(d instanceof gr)t=d,r=d.children.length;else{c=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let u=c.node;if(u){if(u!=n.child(i-1))break;--i,s.set(c,i),l.push(c)}}return{index:i,matched:s,matches:l.reverse()}}function rv(n,e){return n.type.side-e.type.side}function iv(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let d=0;d<n.childCount;d++){let h=n.child(d);r(h,i,e.forChild(s,h),d),s+=h.nodeSize}return}let l=0,c=[],u=null;for(let d=0;;){let h,p;for(;l<i.length&&i[l].to==s;){let k=i[l++];k.widget&&(h?(p||(p=[h])).push(k):h=k)}if(h)if(p){p.sort(rv);for(let k=0;k<p.length;k++)t(p[k],d,!!u)}else t(h,d,!!u);let y,g;if(u)g=-1,y=u,u=null;else if(d<n.childCount)g=d,y=n.child(d++);else break;for(let k=0;k<c.length;k++)c[k].to<=s&&c.splice(k--,1);for(;l<i.length&&i[l].from<=s&&i[l].to>s;)c.push(i[l++]);let _=s+y.nodeSize;if(y.isText){let k=_;l<i.length&&i[l].from<k&&(k=i[l].from);for(let A=0;A<c.length;A++)c[A].to<k&&(k=c[A].to);k<_&&(u=y.cut(k-s),y=y.cut(0,k-s),_=k,g=-1)}else for(;l<i.length&&i[l].to<_;)l++;let S=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,S,e.forChild(s,y),g),s=_}}function sv(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function ov(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let l=n.child(i++),c=s;if(s+=l.nodeSize,!l.isText)continue;let u=l.text;for(;i<n.childCount;){let d=n.child(i++);if(s+=d.nodeSize,!d.isText)break;u+=d.text}if(s>=t){if(s>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let d=c<r?u.lastIndexOf(e,r-c-1):-1;if(d>=0&&d+e.length+c>=t)return c+d;if(t==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function na(n,e,t,r,i){let s=[];for(let l=0,c=0;l<n.length;l++){let u=n[l],d=c,h=c+=u.size;d>=t||h<=e?s.push(u):(d<e&&s.push(u.slice(0,e-d,r)),i&&(s.push(i),i=void 0),h>t&&s.push(u.slice(t-d,u.size,r)))}return s}function ra(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,l=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(l<0)return null;let c=r.resolve(l),u,d;if(Fs(t)){for(u=l;i&&!i.node;)i=i.parent;let p=i.node;if(i&&p.isAtom&&Q.isSelectable(p)&&i.parent&&!(p.isInline&&Ib(t.focusNode,t.focusOffset,i.dom))){let y=i.posBefore;d=new Q(l==y?c:r.resolve(y))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=l,y=l;for(let g=0;g<t.rangeCount;g++){let _=t.getRangeAt(g);p=Math.min(p,n.docView.posFromDOM(_.startContainer,_.startOffset,1)),y=Math.max(y,n.docView.posFromDOM(_.endContainer,_.endOffset,-1))}if(p<0)return null;[u,l]=y==n.state.selection.anchor?[y,p]:[p,y],c=r.resolve(l)}else u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!d){let p=e=="pointer"||n.state.selection.head<c.pos&&!s?1:-1;d=sa(n,h,c,p)}return d}function Xd(n){return n.editable?n.hasFocus():sh(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function vn(n,e=!1){let t=n.state.selection;if(nh(n,t),!!Xd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&nt){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&hr(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)av(n);else{let{anchor:r,head:i}=t,s,l;Zd&&!(t instanceof re)&&(t.$from.parent.inlineContent||(s=eh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=eh(n,t.to))),n.docView.setSelection(r,i,n,e),Zd&&(s&&th(s),l&&th(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lv(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zd=at||nt&&Id<63;function eh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(at&&i&&i.contentEditable=="false")return ia(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return ia(i);if(s)return ia(s)}}function ia(n){return n.contentEditable="true",at&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function th(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lv(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Xd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function av(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,Ye(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&gt&&zn<=11&&(r.disabled=!0,r.disabled=!1)}function nh(n,e){if(e instanceof Q){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(rh(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else rh(n)}function rh(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function sa(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function ih(n){return n.editable&&!n.hasFocus()?!1:sh(n)}function sh(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cv(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return hr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function oa(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&oe.findFrom(s,e)}function Vn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function oh(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let l=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Vn(n,new re(r.$anchor,l))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=oa(n.state,e);return i&&i instanceof Q?Vn(n,i):!1}else if(!(Rt&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!s||s.isText)return!1;let c=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(l=n.docView.descAt(c))&&!l.contentDOM?Q.isSelectable(s)?Vn(n,new Q(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ri?Vn(n,new re(n.state.doc.resolve(e<0?c:c+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Q&&r.node.isInline)return Vn(n,new re(e>0?r.$to:r.$from));{let i=oa(n.state,e);return i?Vn(n,i):!1}}}function $s(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Fi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Jr(n,e){return e<0?uv(n):fv(n)}function uv(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,l=!1;for(qt&&t.nodeType==1&&r<$s(t)&&Fi(t.childNodes[r],-1)&&(l=!0);;)if(r>0){if(t.nodeType!=1)break;{let c=t.childNodes[r-1];if(Fi(c,-1))i=t,s=--r;else if(c.nodeType==3)t=c,r=t.nodeValue.length;else break}}else{if(lh(t))break;{let c=t.previousSibling;for(;c&&Fi(c,-1);)i=t.parentNode,s=Ye(c),c=c.previousSibling;if(c)t=c,r=$s(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}l?la(n,t,r):i&&la(n,i,s)}function fv(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=$s(t),s,l;for(;;)if(r<i){if(t.nodeType!=1)break;let c=t.childNodes[r];if(Fi(c,1))s=t,l=++r;else break}else{if(lh(t))break;{let c=t.nextSibling;for(;c&&Fi(c,1);)s=c.parentNode,l=Ye(c)+1,c=c.nextSibling;if(c)t=c,r=0,i=$s(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&la(n,s,l)}function lh(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function dv(n,e){for(;n&&e==n.childNodes.length&&!Pi(n);)e=Ye(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function hv(n,e){for(;n&&!e&&!Pi(n);)e=Ye(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function la(n,e,t){if(e.nodeType!=3){let s,l;(l=dv(e,t))?(e=l,t=0):(s=hv(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fs(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&vn(n)},50)}function ah(n,e){let t=n.state.doc.resolve(e);if(!(nt||Db)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ch(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||Rt&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let l=oa(n.state,e);if(l&&l instanceof Q)return Vn(n,l)}if(!i.parent.inlineContent){let l=e<0?i:s,c=r instanceof xt?oe.near(l,e):oe.findFrom(l,e);return c?Vn(n,c):!1}return!1}function uh(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let l=n.state.tr;return e<0?l.delete(t.pos-s.nodeSize,t.pos):l.delete(t.pos,t.pos+s.nodeSize),n.dispatch(l),!0}return!1}function fh(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function pv(n){if(!at||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fh(n,r,"true"),setTimeout(()=>fh(n,r,"false"),20)}return!1}function mv(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gv(n,e){let t=e.keyCode,r=mv(e);if(t==8||Rt&&t==72&&r=="c")return uh(n,-1)||Jr(n,-1);if(t==46&&!e.shiftKey||Rt&&t==68&&r=="c")return uh(n,1)||Jr(n,1);if(t==13||t==27)return!0;if(t==37||Rt&&t==66&&r=="c"){let i=t==37?ah(n,n.state.selection.from)=="ltr"?-1:1:-1;return oh(n,i,r)||Jr(n,i)}else if(t==39||Rt&&t==70&&r=="c"){let i=t==39?ah(n,n.state.selection.from)=="ltr"?1:-1:1;return oh(n,i,r)||Jr(n,i)}else{if(t==38||Rt&&t==80&&r=="c")return ch(n,-1,r)||Jr(n,-1);if(t==40||Rt&&t==78&&r=="c")return pv(n)||ch(n,1,r)||Jr(n,1);if(r==(Rt?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function aa(n,e){n.someProp("transformCopied",g=>{e=g(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let g=r.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let l=n.someProp("clipboardSerializer")||dr.fromSchema(n.state.schema),c=bh(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));let d=u.firstChild,h,p=0;for(;d&&d.nodeType==1&&(h=yh[d.nodeName.toLowerCase()]);){for(let g=h.length-1;g>=0;g--){let _=c.createElement(h[g]);for(;u.firstChild;)_.appendChild(u.firstChild);u.appendChild(_),p++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${s}${p?` -${p}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,`
172
174
 
173
175
  `);return{dom:u,text:y,slice:e}}function dh(n,e,t,r,i){let s=i.parent.type.spec.code,l,c;if(!t&&!e)return null;let u=e&&(r||s||!t);if(u){if(n.someProp("transformPastedText",y=>{e=y(e,s||r,n)}),s)return e?new H(D.from(n.state.schema.text(e.replace(/\r\n?/g,`
174
- `))),0,0):H.empty;let p=n.someProp("clipboardTextParser",y=>y(e,i,r,n));if(p)c=p;else{let y=i.marks(),{schema:g}=n.state,_=fr.fromSchema(g);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(S=>{let k=l.appendChild(document.createElement("p"));S&&k.appendChild(_.serializeNode(g.text(S,y)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),l=vv(t),Ri&&wv(l);let d=l&&l.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let p=+h[3];p>0;p--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(c||(c=(n.someProp("clipboardParser")||n.someProp("domParser")||Rn.fromSchema(n.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!yv.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)c=Sv(gh(c,+h[1],+h[2]),h[4]);else if(c=H.maxOpen(_v(c.content,i),!0),c.openStart||c.openEnd){let p=0,y=0;for(let g=c.content.firstChild;p<c.openStart&&!g.type.spec.isolating;p++,g=g.firstChild);for(let g=c.content.lastChild;y<c.openEnd&&!g.type.spec.isolating;y++,g=g.lastChild);c=gh(c,p,y)}return n.someProp("transformPasted",p=>{c=p(c,n)}),c}const yv=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function _v(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,l=[];if(n.forEach(c=>{if(!l)return;let u=i.findWrapping(c.type),d;if(!u)return l=null;if(d=l.length&&s.length&&ph(u,s,c,l[l.length-1],0))l[l.length-1]=d;else{l.length&&(l[l.length-1]=mh(l[l.length-1],s.length));let h=hh(c,u);l.push(h),i=i.matchType(h.type),s=u}}),l)return D.from(l)}return n}function hh(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,D.from(n));return n}function ph(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=ph(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(D.from(hh(t,n,i+1))))}}function mh(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,mh(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(D.empty,!0);return n.copy(t.append(r))}function ca(n,e,t,r,i,s){let l=e<0?n.firstChild:n.lastChild,c=l.content;return n.childCount>1&&(s=0),i<r-1&&(c=ca(c,e,t,r,i+1,s)),i>=t&&(c=e<0?l.contentMatchAt(0).fillBefore(c,s<=i).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(D.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,l.copy(c))}function gh(n,e,t){return e<n.openStart&&(n=new H(ca(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new H(ca(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const yh={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _h=null;function bh(){return _h||(_h=document.implementation.createHTMLDocument("title"))}let ua=null;function bv(n){let e=window.trustedTypes;return e?(ua||(ua=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ua.createHTML(n)):n}function vv(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=bh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&yh[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=bv(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function wv(n){let e=n.querySelectorAll(nt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Sv(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:l}=n;for(let c=r.length-2;c>=0;c-=2){let u=t.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=D.from(u.create(r[c+1],i)),s++,l++}return new H(i,s,l)}const ct={},ut={},kv={touchstart:!0,touchmove:!0};class xv{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ev(n){for(let e in ct){let t=ct[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ov(n,r)&&!da(n,r)&&(n.editable||!(r.type in ut))&&t(n,r)},kv[e]?{passive:!0}:void 0)}at&&n.dom.addEventListener("input",()=>null),fa(n)}function Hn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Tv(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function fa(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>da(n,r))})}function da(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ov(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Av(n,e){!da(n,e)&&ct[e.type]&&(n.editable||!(e.type in ut))&&ct[e.type](n,e)}ut.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wh(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(_n&&nt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),jr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,hr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||gv(n,t)?t.preventDefault():Hn(n,"key")},ut.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ut.keypress=(n,e)=>{let t=e;if(wh(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Rt&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof re)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Vs(n){return{left:n.clientX,top:n.clientY}}function Cv(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ha(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let l=s.depth+1;l>0;l--)if(n.someProp(e,c=>l>s.depth?c(n,t,s.nodeAfter,s.before(l),i,!0):c(n,t,s.node(l),s.before(l),i,!1)))return!0;return!1}function Gr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Mv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Q.isSelectable(r)?(Gr(n,new Q(t)),!0):!1}function Nv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Q&&(r=t.node);let s=n.state.doc.resolve(e);for(let l=s.depth+1;l>0;l--){let c=l>s.depth?s.nodeAfter:s.node(l);if(Q.isSelectable(c)){r&&t.$from.depth>0&&l>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(l);break}}return i!=null?(Gr(n,Q.create(n.state.doc,i)),!0):!1}function Iv(n,e,t,r,i){return ha(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Nv(n,t):Mv(n,t))}function Pv(n,e,t,r){return ha(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Rv(n,e,t,r){return ha(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Dv(n,t,r)}function Dv(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Gr(n,re.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(l.inlineContent)Gr(n,re.create(r,c+1,c+1+l.content.size));else if(Q.isSelectable(l))Gr(n,Q.create(r,c));else continue;return!0}}function pa(n){return Hs(n)}const vh=Rt?"metaKey":"ctrlKey";ct.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pa(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Cv(t,n.input.lastClick)&&!t[vh]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let l=n.posAtCoords(Vs(t));l&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lv(n,l,t,!!r)):(s=="doubleClick"?Pv:Rv)(n,l.pos,l.inside,t)?t.preventDefault():Hn(n,"pointer"))};class Lv{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[vh],this.allowDefault=r.shiftKey;let s,l;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),l=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,l=h.depth?h.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.dom.nodeType==1?u.dom:null;let{selection:d}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof Q&&d.from<=l&&d.to>l)&&(this.mightDrag={node:s,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Hn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>vn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Vs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Hn(this.view,"pointer"):Iv(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||at&&this.mightDrag&&!this.mightDrag.node.isAtom||nt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Gr(this.view,oe.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Hn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Hn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ct.touchstart=n=>{n.input.lastTouch=Date.now(),pa(n),Hn(n,"pointer")},ct.touchmove=n=>{n.input.lastTouch=Date.now(),Hn(n,"pointer")},ct.contextmenu=n=>pa(n);function wh(n,e){return n.composing?!0:at&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Bv=_n?5e3:-1;ut.compositionstart=ut.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof re&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Hs(n,!0),n.markCursor=null;else if(Hs(n,!e.selection.empty),qt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let l=s<0?i.lastChild:i.childNodes[s-1];if(!l)break;if(l.nodeType==3){let c=n.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else i=l,s=-1}}n.input.composing=!0}Sh(n,Bv)},ut.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Sh(n,20))};function Sh(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Hs(n),e))}function kh(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=zv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Fv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Mb(e.focusNode,e.focusOffset),r=Nb(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let l=t.pmViewDesc;if(!(!l||!l.isText(t.nodeValue)))return r}}return t||r}function zv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Hs(n,e=!1){if(!(_n&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),kh(n),e||n.docView&&n.docView.dirty){let t=ra(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Wv(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const zi=gt&&zn<15||jr&&Lb<604;ct.copy=ut.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=zi?null:t.clipboardData,l=r.content(),{dom:c,text:u}=aa(n,l);s?(t.preventDefault(),s.clearData(),s.setData("text/html",c.innerHTML),s.setData("text/plain",u)):Wv(n,c),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $v(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Vv(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Wi(n,r.value,null,i,e):Wi(n,r.textContent,r.innerHTML,i,e)},50)}function Wi(n,e,t,r,i){let s=dh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",u=>u(n,i,s||H.empty)))return!0;if(!s)return!1;let l=$v(s),c=l?n.state.tr.replaceSelectionWith(l,r):n.state.tr.replaceSelection(s);return n.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function xh(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ut.paste=(n,e)=>{let t=e;if(n.composing&&!_n)return;let r=zi?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Wi(n,xh(r),r.getData("text/html"),i,t)?t.preventDefault():Vv(n,t)};class Eh{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Th=Rt?"altKey":"ctrlKey";ct.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Vs(t)),l;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Q?i.to-1:i.to))){if(r&&r.mightDrag)l=Q.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(l=Q.create(n.state.doc,p.posBefore))}}let c=(l||n.state.selection).content(),{dom:u,text:d,slice:h}=aa(n,c);(!t.dataTransfer.files.length||!nt||Id>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(zi?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",zi||t.dataTransfer.setData("text/plain",d),n.dragging=new Eh(h,!t[Th],l)},ct.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ut.dragover=ut.dragenter=(n,e)=>e.preventDefault(),ut.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Vs(t));if(!i)return;let s=n.state.doc.resolve(i.pos),l=r&&r.slice;l?n.someProp("transformPasted",_=>{l=_(l,n)}):l=dh(n,xh(t.dataTransfer),zi?null:t.dataTransfer.getData("text/html"),!1,s);let c=!!(r&&!t[Th]);if(n.someProp("handleDrop",_=>_(n,t,l||H.empty,c))){t.preventDefault();return}if(!l)return;t.preventDefault();let u=l?md(n.state.doc,s.pos,l):s.pos;u==null&&(u=s.pos);let d=n.state.tr;if(c){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let h=d.mapping.map(u),p=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,y=d.doc;if(p?d.replaceRangeWith(h,h,l.content.firstChild):d.replaceRange(h,h,l),d.doc.eq(y))return;let g=d.doc.resolve(h);if(p&&Q.isSelectable(l.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(l.content.firstChild))d.setSelection(new Q(g));else{let _=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((S,k,A,P)=>_=P),d.setSelection(sa(n,g,d.doc.resolve(_)))}n.focus(),n.dispatch(d.setMeta("uiEvent","drop"))},ct.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&vn(n)},20))},ct.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ct.beforeinput=(n,e)=>{if(nt&&_n&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,hr(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ut)ct[n]=ut[n];function $i(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Us{constructor(e,t){this.toDOM=e,this.spec=t||yr,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:l}=e.mapResult(t.from+i,this.side<0?-1:1);return l?null:new Lt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Us&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$i(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Un{constructor(e,t){this.attrs=e,this.spec=t||yr}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=l?null:new Lt(s,l,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Un&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}static is(e){return e.type instanceof Un}destroy(){}}class ma{constructor(e,t){this.attrs=e,this.spec=t||yr}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let l=e.mapResult(t.to+i,-1);return l.deleted||l.pos<=s.pos?null:new Lt(s.pos-r,l.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ma&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}destroy(){}}class Lt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Lt(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Lt(e,e,new Us(t,r))}static inline(e,t,r,i){return new Lt(e,t,new Un(r,i))}static node(e,t,r,i){return new Lt(e,t,new ma(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Un}get widget(){return this.type instanceof Us}}const Yr=[],yr={};class Be{constructor(e,t){this.local=e.length?e:Yr,this.children=t.length?t:Yr}static create(e,t){return t.length?Ks(t,e,0,yr):rt}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let l=0;l<this.local.length;l++){let c=this.local[l];c.from<=t&&c.to>=e&&(!s||s(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<t&&this.children[l+1]>e){let c=this.children[l]+1;this.children[l+2].findInner(e-c,t-c,r,i+c,s)}}map(e,t,r){return this==rt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||yr)}mapInner(e,t,r,i,s){let l;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,i);u&&u.type.valid(t,u)?(l||(l=[])).push(u):s.onRemove&&s.onRemove(this.local[c].spec)}return this.children.length?Hv(this.children,l||[],e,t,r,i,s):l?new Be(l.sort(_r),Yr):rt}add(e,t){return t.length?this==rt?Be.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((c,u)=>{let d=u+r,h;if(h=Ah(t,c,d)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(c,h,d+1):i.splice(s,0,u,u+c.nodeSize,Ks(h,c,d+1,yr)),s+=3}});let l=Oh(s?Ch(t):t,-r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||l.splice(c--,1);return new Be(l.length?this.local.concat(l).sort(_r):this.local,i||this.children)}remove(e){return e.length==0||this==rt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let l,c=r[s]+t,u=r[s+1]+t;for(let h=0,p;h<e.length;h++)(p=e[h])&&p.from>c&&p.to<u&&(e[h]=null,(l||(l=[])).push(p));if(!l)continue;r==this.children&&(r=this.children.slice());let d=r[s+2].removeInner(l,c+1);d!=rt?r[s+2]=d:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,l;s<e.length;s++)if(l=e[s])for(let c=0;c<i.length;c++)i[c].eq(l,t)&&(i==this.local&&(i=this.local.slice()),i.splice(c--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Be(i,r):rt}forChild(e,t){if(this==rt)return this;if(t.isLeaf)return Be.empty;let r,i;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let s=e+1,l=s+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<l&&u.to>s&&u.type instanceof Un){let d=Math.max(s,u.from)-s,h=Math.min(l,u.to)-s;d<h&&(i||(i=[])).push(u.copy(d,h))}}if(i){let c=new Be(i.sort(_r),Yr);return r?new Kn([c,r]):c}return r||rt}eq(e){if(this==e)return!0;if(!(e instanceof Be)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ga(this.localsInner(e))}localsInner(e){if(this==rt)return Yr;if(e.inlineContent||!this.local.some(Un.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Un||t.push(this.local[r]);return t}forEachSet(e){e(this)}}Be.empty=new Be([],[]),Be.removeOverlap=ga;const rt=Be.empty;class Kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,yr));return Kn.from(r)}forChild(e,t){if(t.isLeaf)return Be.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=rt&&(s instanceof Kn?r=r.concat(s.members):r.push(s))}return Kn.from(r)}eq(e){if(!(e instanceof Kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let l=0;l<s.length;l++)t.push(s[l])}}return t?ga(r?t:t.sort(_r)):Yr}static from(e){switch(e.length){case 0:return rt;case 1:return e[0];default:return new Kn(e.every(t=>t instanceof Be)?e:e.reduce((t,r)=>t.concat(r instanceof Be?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Hv(n,e,t,r,i,s,l){let c=n.slice();for(let d=0,h=s;d<t.maps.length;d++){let p=0;t.maps[d].forEach((y,g,_,S)=>{let k=S-_-(g-y);for(let A=0;A<c.length;A+=3){let P=c[A+1];if(P<0||y>P+h-p)continue;let L=c[A]+h-p;g>=L?c[A+1]=y<=L?-2:-1:y>=h&&k&&(c[A]+=k,c[A+1]+=k)}p+=k}),h=t.maps[d].map(h,-1)}let u=!1;for(let d=0;d<c.length;d+=3)if(c[d+1]<0){if(c[d+1]==-2){u=!0,c[d+1]=-1;continue}let h=t.map(n[d]+s),p=h-i;if(p<0||p>=r.content.size){u=!0;continue}let y=t.map(n[d+1]+s,-1),g=y-i,{index:_,offset:S}=r.content.findIndex(p),k=r.maybeChild(_);if(k&&S==p&&S+k.nodeSize==g){let A=c[d+2].mapInner(t,k,h+1,n[d]+s+1,l);A!=rt?(c[d]=p,c[d+1]=g,c[d+2]=A):(c[d+1]=-2,u=!0)}else u=!0}if(u){let d=Uv(c,n,e,t,i,s,l),h=Ks(d,r,0,l);e=h.local;for(let p=0;p<c.length;p+=3)c[p+1]<0&&(c.splice(p,3),p-=3);for(let p=0,y=0;p<h.children.length;p+=3){let g=h.children[p];for(;y<c.length&&c[y]<g;)y+=3;c.splice(y,0,h.children[p],h.children[p+1],h.children[p+2])}}return new Be(e.sort(_r),c)}function Oh(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Lt(i.from+e,i.to+e,i.type))}return t}function Uv(n,e,t,r,i,s,l){function c(u,d){for(let h=0;h<u.local.length;h++){let p=u.local[h].map(r,i,d);p?t.push(p):l.onRemove&&l.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)c(u.children[h+2],u.children[h]+d+1)}for(let u=0;u<n.length;u+=3)n[u+1]==-1&&c(n[u+2],e[u]+s+1);return t}function Ah(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,l;s<n.length;s++)(l=n[s])&&l.from>t&&l.to<r&&((i||(i=[])).push(l),n[s]=null);return i}function Ch(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ks(n,e,t,r){let i=[],s=!1;e.forEach((c,u)=>{let d=Ah(n,c,u+t);if(d){s=!0;let h=Ks(d,c,t+u+1,r);h!=rt&&i.push(u,u+c.nodeSize,h)}});let l=Oh(s?Ch(n):n,-t).sort(_r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||(r.onRemove&&r.onRemove(l[c].spec),l.splice(c--,1));return l.length||i.length?new Be(l,i):rt}function _r(n,e){return n.from-e.from||n.to-e.to}function ga(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Mh(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Mh(e,i,r.copy(s.from,r.to)));break}}}return e}function Mh(n,e,t){for(;e<n.length&&_r(t,n[e])>0;)e++;n.splice(e,0,t)}function ya(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=rt&&e.push(r)}),n.cursorWrapper&&e.push(Be.create(n.state.doc,[n.cursorWrapper.deco])),Kn.from(e)}const Kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jv=gt&&zn<=11;class qv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Jv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);gt&&zn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),jv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Kv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ih(this.view)){if(this.suppressingSelectionUpdates)return vn(this.view);if(gt&&zn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&dr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Kr(s))t.add(s);for(let s=e.anchorNode;s;s=Kr(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ih(e)&&!this.ignoreSelectionChange(r),s=-1,l=-1,c=!1,u=[];if(e.editable)for(let h=0;h<t.length;h++){let p=this.registerMutation(t[h],u);p&&(s=s<0?p.from:Math.min(p.from,s),l=l<0?p.to:Math.max(p.to,l),p.typeOver&&(c=!0))}if(qt&&u.length){let h=u.filter(p=>p.nodeName=="BR");if(h.length==2){let[p,y]=h;p.parentNode&&p.parentNode.parentNode==y.parentNode?y.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let y of h){let g=y.parentNode;g&&g.nodeName=="LI"&&(!p||Qv(e,p)!=g)&&y.remove()}}}let d=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fs(r)&&(d=ra(e))&&d.eq(oe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,vn(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,l),Gv(e)),this.handleDOMChange(s,l,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||vn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let p=e.addedNodes[h];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(gt&&zn<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:p,nextSibling:y}=e.addedNodes[h];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(s=y)}let l=i&&i.parentNode==e.target?Ye(i)+1:0,c=r.localPosFromDOM(e.target,l,-1),u=s&&s.parentNode==e.target?Ye(s):e.target.childNodes.length,d=r.localPosFromDOM(e.target,u,1);return{from:c,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Nh=new WeakMap,Ih=!1;function Gv(n){if(!Nh.has(n)&&(Nh.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=qt,Ih)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Ih=!0}}function Ph(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,l=n.domAtPos(n.state.selection.anchor);return dr(l.node,l.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Yv(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Ph(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ph(n,t):null}function Qv(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Xv(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:l,to:c}=n.docView.parseRange(e,t),u=n.domSelectionRange(),d,h=u.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(d=[{node:h,offset:u.anchorOffset}],Fs(u)||d.push({node:u.focusNode,offset:u.focusOffset})),nt&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let A=r.childNodes[k-1],P=A.pmViewDesc;if(A.nodeName=="BR"&&!P){s=k;break}if(!P||P.size)break}let p=n.state.doc,y=n.someProp("domParser")||Rn.fromSchema(n.state.schema),g=p.resolve(l),_=null,S=y.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Zv,context:g});if(d&&d[0].pos!=null){let k=d[0].pos,A=d[1]&&d[1].pos;A==null&&(A=k),_={anchor:k+l,head:A+l}}return{doc:S,sel:_,from:l,to:c}}function Zv(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(at&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||at&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ew=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tw(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let V=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ne=ra(n,V);if(ne&&!n.state.selection.eq(ne)){if(nt&&_n&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Le=>Le(n,hr(13,"Enter"))))return;let ve=n.state.tr.setSelection(ne);V=="pointer"?ve.setMeta("pointer",!0):V=="key"&&ve.scrollIntoView(),s&&ve.setMeta("composition",s),n.dispatch(ve)}return}let l=n.state.doc.resolve(e),c=l.sharedDepth(t);e=l.before(c+1),t=n.state.doc.resolve(t).after(c+1);let u=n.state.selection,d=Xv(n,e,t),h=n.state.doc,p=h.slice(d.from,d.to),y,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(y=n.state.selection.to,g="end"):(y=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let _=iw(p.content,d.doc.content,d.from,y,g);if(_&&n.input.domChangeCount++,(jr&&n.input.lastIOSEnter>Date.now()-225||_n)&&i.some(V=>V.nodeType==1&&!ew.test(V.nodeName))&&(!_||_.endA>=_.endB)&&n.someProp("handleKeyDown",V=>V(n,hr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!_)if(r&&u instanceof re&&!u.empty&&u.$head.sameParent(u.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))_={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let V=Rh(n,n.state.doc,d.sel);if(V&&!V.eq(n.state.selection)){let ne=n.state.tr.setSelection(V);s&&ne.setMeta("composition",s),n.dispatch(ne)}}return}n.state.selection.from<n.state.selection.to&&_.start==_.endB&&n.state.selection instanceof re&&(_.start>n.state.selection.from&&_.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?_.start=n.state.selection.from:_.endA<n.state.selection.to&&_.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(_.endB+=n.state.selection.to-_.endA,_.endA=n.state.selection.to)),gt&&zn<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>d.from&&d.doc.textBetween(_.start-d.from-1,_.start-d.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let S=d.doc.resolveNoCache(_.start-d.from),k=d.doc.resolveNoCache(_.endB-d.from),A=h.resolve(_.start),P=S.sameParent(k)&&S.parent.inlineContent&&A.end()>=_.endA,L;if((jr&&n.input.lastIOSEnter>Date.now()-225&&(!P||i.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!P&&S.pos<d.doc.content.size&&!S.sameParent(k)&&(L=oe.findFrom(d.doc.resolve(S.pos+1),1,!0))&&L.head==k.pos)&&n.someProp("handleKeyDown",V=>V(n,hr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>_.start&&rw(h,_.start,_.endA,S,k)&&n.someProp("handleKeyDown",V=>V(n,hr(8,"Backspace")))){_n&&nt&&n.domObserver.suppressSelectionUpdates();return}nt&&_.endB==_.start&&(n.input.lastChromeDelete=Date.now()),_n&&!P&&S.start()!=k.start()&&k.parentOffset==0&&S.depth==k.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==_.endA&&(_.endB-=2,k=d.doc.resolveNoCache(_.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(V){return V(n,hr(13,"Enter"))})},20));let B=_.start,W=_.endA,z,J,j;if(P){if(S.pos==k.pos)gt&&zn<=11&&S.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>vn(n),20)),z=n.state.tr.delete(B,W),J=h.resolve(_.start).marksAcross(h.resolve(_.endA));else if(_.endA==_.endB&&(j=nw(S.parent.content.cut(S.parentOffset,k.parentOffset),A.parent.content.cut(A.parentOffset,_.endA-A.start()))))z=n.state.tr,j.type=="add"?z.addMark(B,W,j.mark):z.removeMark(B,W,j.mark);else if(S.parent.child(S.index()).isText&&S.index()==k.index()-(k.textOffset?0:1)){let V=S.parent.textBetween(S.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",ne=>ne(n,B,W,V)))return;z=n.state.tr.insertText(V,B,W)}}if(z||(z=n.state.tr.replace(B,W,d.doc.slice(_.start-d.from,_.endB-d.from))),d.sel){let V=Rh(n,z.doc,d.sel);V&&!(nt&&n.composing&&V.empty&&(_.start!=_.endB||n.input.lastChromeDelete<Date.now()-100)&&(V.head==B||V.head==z.mapping.map(W)-1)||gt&&V.empty&&V.head==B)&&z.setSelection(V)}J&&z.ensureMarks(J),s&&z.setMeta("composition",s),n.dispatch(z.scrollIntoView())}function Rh(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:sa(n,e.resolve(t.anchor),e.resolve(t.head))}function nw(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,l,c,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)c=i[0],l="add",u=h=>h.mark(c.addToSet(h.marks));else if(i.length==0&&s.length==1)c=s[0],l="remove",u=h=>h.mark(c.removeFromSet(h.marks));else return null;let d=[];for(let h=0;h<e.childCount;h++)d.push(u(e.child(h)));if(D.from(d).eq(n))return{mark:c,type:l}}function rw(n,e,t,r,i){if(t-e<=i.pos-r.pos||_a(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let c=s.nodeAfter;return c!=null&&t==e+c.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let l=n.resolve(_a(s,!0,!0));return!l.parent.isTextblock||l.pos>t||_a(l,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function _a(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function iw(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:l,b:c}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let u=Math.max(0,s-Math.min(l,c));r-=l+u-s}if(l<s&&n.size<e.size){let u=r<=s&&r>=l?s-r:0;s-=u,s&&s<e.size&&Dh(e.textBetween(s-1,s+1))&&(s+=u?1:-1),c=s+(c-l),l=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,s&&s<n.size&&Dh(n.textBetween(s-1,s+1))&&(s+=u?1:-1),l=s+(l-c),c=s}return{start:s,endA:l,endB:c}}function Dh(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class sw{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new xv,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Wh),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Fh(this),Bh(this),this.nodeViews=zh(this),this.docView=jd(this.state.doc,Lh(this),ya(this),this.dom,this),this.domObserver=new Jv(this,(r,i,s,l)=>tw(this,r,i,s,l)),this.domObserver.start(),Ev(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Wh),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,l=!1;e.storedMarks&&this.composing&&(kh(this),l=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(c||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=zh(this);lw(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(c||t.handleDOMEvents!=this._props.handleDOMEvents)&&fa(this),this.editable=Fh(this),Bh(this);let u=ya(this),d=Lh(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=s||!this.docView.matchesNode(e.doc,d,u);(p||!e.selection.eq(i.selection))&&(l=!0);let y=h=="preserve"&&l&&this.dom.style.overflowAnchor==null&&zb(this);if(l){this.domObserver.stop();let g=p&&(gt||nt)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ow(i.selection,e.selection);if(p){let _=nt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Fv(this)),(s||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=jd(e.doc,d,u,this.dom,this)),_&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cv(this))?vn(this,g):(nh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&Wb(y)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Q){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pd(this,t.getBoundingClientRect(),e)}else Pd(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Eh(e.slice,e.move,i<0?void 0:Q.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let l=0;l<this.directPlugins.length;l++){let c=this.directPlugins[l].props[e];if(c!=null&&(i=t?t(c):c))return i}let s=this.state.plugins;if(s)for(let l=0;l<s.length;l++){let c=s[l].props[e];if(c!=null&&(i=t?t(c):c))return i}}hasFocus(){if(gt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&$b(this.dom),vn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return jb(this,e)}coordsAtPos(e,t=1){return zd(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Qb(this,t||this.state,e)}pasteHTML(e,t){return Wi(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Wi(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return aa(this,e)}destroy(){this.docView&&(Tv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ya(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ab())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Av(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?at&&this.root.nodeType===11&&Pb(this.dom.ownerDocument)==this.dom&&Yv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Lh(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Lt.node(0,n.state.doc.content.size,e)]}function Bh(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Lt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Fh(n){return!n.someProp("editable",e=>e(n.state)===!1)}function ow(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function zh(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lw(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Wh(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var jn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},js={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},aw=typeof navigator<"u"&&/Mac/.test(navigator.platform),cw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Qe=0;Qe<10;Qe++)jn[48+Qe]=jn[96+Qe]=String(Qe);for(var Qe=1;Qe<=24;Qe++)jn[Qe+111]="F"+Qe;for(var Qe=65;Qe<=90;Qe++)jn[Qe]=String.fromCharCode(Qe+32),js[Qe]=String.fromCharCode(Qe);for(var ba in jn)js.hasOwnProperty(ba)||(js[ba]=jn[ba]);function uw(n){var e=aw&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||cw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?js:jn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const fw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function dw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,l;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))fw?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),l&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function hw(n){let e=Object.create(null);for(let t in n)e[dw(t)]=n[t];return e}function va(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function pw(n){return new mt({props:{handleKeyDown:$h(n)}})}function $h(n){let e=hw(n);return function(t,r){let i=uw(r),s,l=e[va(i,r)];if(l&&l(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let c=e[va(i,r,!1)];if(c&&c(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=jn[r.keyCode])&&s!=i){let c=e[va(s,r)];if(c&&c(t.state,t.dispatch,t))return!0}}return!1}}const wa=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Vh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hh=(n,e,t)=>{let r=Vh(n,t);if(!r)return!1;let i=Sa(r);if(!i){let l=r.blockRange(),c=l&&Wr(l);return c==null?!1:(e&&e(n.tr.lift(l,c).scrollIntoView()),!0)}let s=i.nodeBefore;if(Xh(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Qr(s,"end")||Q.isSelectable(s)))for(let l=r.depth;;l--){let c=Ls(n.doc,r.before(l),r.after(l),H.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=n.tr.step(c);u.setSelection(Qr(s,"end")?oe.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Q.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(l==1||r.node(l-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},mw=(n,e,t)=>{let r=Vh(n,t);if(!r)return!1;let i=Sa(r);return i?Uh(n,i,e):!1},gw=(n,e,t)=>{let r=jh(n,t);if(!r)return!1;let i=ka(r);return i?Uh(n,i,e):!1};function Uh(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let l=e.nodeAfter,c=l,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let d=Ls(n.doc,s,u,H.empty);if(!d||d.from!=s||d instanceof $e&&d.slice.size>=u-s)return!1;if(t){let h=n.tr.step(d);h.setSelection(re.create(h.doc,s)),t(h.scrollIntoView())}return!0}function Qr(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Kh=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Sa(r)}let l=s&&s.nodeBefore;return!l||!Q.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)};function Sa(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function jh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const qh=(n,e,t)=>{let r=jh(n,t);if(!r)return!1;let i=ka(r);if(!i)return!1;let s=i.nodeAfter;if(Xh(n,i,e,1))return!0;if(r.parent.content.size==0&&(Qr(s,"start")||Q.isSelectable(s))){let l=Ls(n.doc,r.before(),r.after(),H.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Qr(s,"start")?oe.findFrom(c.doc.resolve(c.mapping.map(i.pos)),1):Q.create(c.doc,c.mapping.map(i.pos))),e(c.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Jh=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=ka(r)}let l=s&&s.nodeAfter;return!l||!Q.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos)).scrollIntoView()),!0)};function ka(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const yw=(n,e)=>{let t=n.selection,r=t instanceof Q,i;if(r){if(t.node.isTextblock||!Bn(n.doc,t.from))return!1;i=t.from}else if(i=Ds(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(Q.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},_w=(n,e)=>{let t=n.selection,r;if(t instanceof Q){if(t.node.isTextblock||!Bn(n.doc,t.to))return!1;r=t.to}else if(r=Ds(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},bw=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Wr(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Gh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
175
- `).scrollIntoView()),!0)};function xa(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const vw=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),l=xa(i.contentMatchAt(s));if(!l||!i.canReplaceWith(s,s,l))return!1;if(e){let c=t.after(),u=n.tr.replaceWith(c,c,l.createAndFill());u.setSelection(oe.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Yh=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof xt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=xa(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let l=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,c=n.tr.insert(l,s.createAndFill());c.setSelection(re.create(c.doc,l+1)),e(c.scrollIntoView())}return!0},Qh=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(gn(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Wr(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function ww(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Q&&e.selection.node.isBlock)return!r.parentOffset||!gn(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],l,c,u=!1,d=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){u=r.end(g)==r.pos+(r.depth-g),d=r.start(g)==r.pos-(r.depth-g),c=xa(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),s.unshift(u&&c?{type:c}:null),l=g;break}else{if(g==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof re||e.selection instanceof xt)&&h.deleteSelection();let p=h.mapping.map(r.pos),y=gn(h.doc,p,s.length,s);if(y||(s[0]=c?{type:c}:null,y=gn(h.doc,p,s.length,s)),h.split(p,s.length,s),!u&&d&&r.node(l).type!=c){let g=h.mapping.map(r.before(l)),_=h.doc.resolve(g);c&&r.node(l-1).canReplaceWith(_.index(),_.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(l)),c)}return t&&t(h.scrollIntoView()),!0}}const Sw=ww(),kw=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(Q.create(n.doc,i))),!0)};function xw(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Bn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Xh(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,l,c,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&xw(n,e,t))return!0;let d=!u&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(l=(c=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&c.matchType(l[0]||s.type).validEnd){if(t){let g=e.pos+s.nodeSize,_=D.empty;for(let A=l.length-1;A>=0;A--)_=D.from(l[A].create(null,_));_=D.from(i.copy(_));let S=n.tr.step(new Ve(e.pos-1,g,e.pos,g,new H(_,1,0),l.length,!0)),k=S.doc.resolve(g+2*l.length);k.nodeAfter&&k.nodeAfter.type==i.type&&Bn(S.doc,k.pos)&&S.join(k.pos),t(S.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&u?null:oe.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),y=p&&Wr(p);if(y!=null&&y>=e.depth)return t&&t(n.tr.lift(p,y).scrollIntoView()),!0;if(d&&Qr(s,"start",!0)&&Qr(i,"end")){let g=i,_=[];for(;_.push(g),!g.isTextblock;)g=g.lastChild;let S=s,k=1;for(;!S.isTextblock;S=S.firstChild)k++;if(g.canReplace(g.childCount,g.childCount,S.content)){if(t){let A=D.empty;for(let L=_.length-1;L>=0;L--)A=D.from(_[L].copy(A));let P=n.tr.step(new Ve(e.pos-_.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new H(A,_.length,0),0,!0));t(P.scrollIntoView())}return!0}}return!1}function Zh(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(re.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Ew=Zh(-1),Tw=Zh(1);function Ow(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,l=i.blockRange(s),c=l&&Vl(l,n,e);return c?(r&&r(t.tr.wrap(l,c).scrollIntoView()),!0):!1}}function ep(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[s];t.doc.nodesBetween(l,c,(u,d)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(n,e)))if(u.type==n)i=!0;else{let h=t.doc.resolve(d),p=h.index();i=h.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let l=0;l<t.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:u}}=t.selection.ranges[l];s.setBlockType(c,u,n,e)}r(s.scrollIntoView())}return!0}}function Ea(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Ea(wa,Hh,Kh),Ea(wa,qh,Jh),Ea(Gh,Yh,Qh,Sw),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Aw(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,l=i.blockRange(s);if(!l)return!1;let c=r?t.tr:null;return Cw(c,l,n,e)?(r&&r(c.scrollIntoView()),!0):!1}}function Cw(n,e,t,r=null){let i=!1,s=e,l=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=l.resolve(e.start-2);s=new As(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new As(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let c=Vl(s,t,r,e);return c?(n&&Mw(n,e,c,i,t),!0):!1}function Mw(n,e,t,r,i){let s=D.empty;for(let h=t.length-1;h>=0;h--)s=D.from(t[h].type.create(t[h].attrs,s));n.step(new Ve(e.start-(r?2:0),e.end,e.start,e.end,new H(s,0,0),t.length,!0));let l=0;for(let h=0;h<t.length;h++)t[h].type==i&&(l=h+1);let c=t.length-l,u=e.start+t.length-(r?2:0),d=e.parent;for(let h=e.startIndex,p=e.endIndex,y=!0;h<p;h++,y=!1)!y&&gn(n.doc,u,c)&&(n.split(u,c),u+=2*c),u+=d.child(h).nodeSize;return n}function Nw(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,l=>l.childCount>0&&l.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Iw(e,t,n,s):Pw(e,t,s):!0:!1}}function Iw(n,e,t,r){let i=n.tr,s=r.end,l=r.$to.end(r.depth);s<l&&(i.step(new Ve(s-1,l,s,l,new H(D.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new As(i.doc.resolve(r.$from.pos),i.doc.resolve(l),r.depth));const c=Wr(r);if(c==null)return!1;i.lift(r,c);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return Bn(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function Pw(n,e,t){let r=n.tr,i=t.parent;for(let g=t.end,_=t.endIndex-1,S=t.startIndex;_>S;_--)g-=i.child(_).nodeSize,r.delete(g-1,g+1);let s=r.doc.resolve(t.start),l=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let c=t.startIndex==0,u=t.endIndex==i.childCount,d=s.node(-1),h=s.index(-1);if(!d.canReplace(h+(c?0:1),h+1,l.content.append(u?D.empty:D.from(i))))return!1;let p=s.pos,y=p+l.nodeSize;return r.step(new Ve(p-(c?1:0),y+(u?1:0),p+1,y-1,new H((c?D.empty:D.from(i.copy(D.empty))).append(u?D.empty:D.from(i.copy(D.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function Rw(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let l=s.startIndex;if(l==0)return!1;let c=s.parent,u=c.child(l-1);if(u.type!=n)return!1;if(t){let d=u.lastChild&&u.lastChild.type==c.type,h=D.from(d?n.create():null),p=new H(D.from(n.create(null,D.from(c.type.create(null,h)))),d?3:1,0),y=s.start,g=s.end;t(e.tr.step(new Ve(y-(d?3:1),g,y,g,p,1,!0)).scrollIntoView())}return!0}}function qs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class Js{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,l=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>{const p=u(...h)(l);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:l}=i,c=[],u=!!e,d=e||s.tr,h=()=>(!u&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(y=>y===!0)),p={...Object.fromEntries(Object.entries(r).map(([y,g])=>[y,(...S)=>{const k=this.buildProps(d,t),A=g(...S)(k);return c.push(A),p}])),run:h};return p}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,l=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...h)=>d(...h)({...l,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:l}=i,c={tr:e,editor:i,view:l,state:qs({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...h)=>d(...h)(c)]))}};return c}}class Dw{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function q(n,e,t){return n.config[e]===void 0&&n.parent?q(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?q(n.parent,e,t):null}):n.config[e]}function Gs(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function tp(n){const e=[],{nodeExtensions:t,markExtensions:r}=Gs(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:i},u=q(l,"addGlobalAttributes",c);if(!u)return;u().forEach(h=>{h.types.forEach(p=>{Object.entries(h.attributes).forEach(([y,g])=>{e.push({type:p,name:y,attribute:{...s,...g}})})})})}),i.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},u=q(l,"addAttributes",c);if(!u)return;const d=u();Object.entries(d).forEach(([h,p])=>{const y={...s,...p};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:l.name,name:h,attribute:y})})}),e}function He(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Fe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const c=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],d=c.filter(h=>!u.includes(h));r[i]=[...u,...d].join(" ")}else if(i==="style"){const c=s?s.split(";").map(h=>h.trim()).filter(Boolean):[],u=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],d=new Map;u.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),c.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),r[i]=Array.from(d.entries()).map(([h,p])=>`${h}: ${p}`).join("; ")}else r[i]=s}),r},{})}function Ta(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Fe(t,r),{})}function np(n){return typeof n=="function"}function ue(n,e=void 0,...t){return np(n)?e?n.bind(e)(...t):n(...t):n}function Lw(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Bw(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function rp(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(t):Bw(t.getAttribute(l.name));return c==null?s:{...s,[l.name]:c}},{});return{...r,...i}}}}function ip(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Lw(t)?!1:t!=null))}function Fw(n,e){var t;const r=tp(n),{nodeExtensions:i,markExtensions:s}=Gs(n),l=(t=i.find(d=>q(d,"topNode")))===null||t===void 0?void 0:t.name,c=Object.fromEntries(i.map(d=>{const h=r.filter(A=>A.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((A,P)=>{const L=q(P,"extendNodeSchema",p);return{...A,...L?L(d):{}}},{}),g=ip({...y,content:ue(q(d,"content",p)),marks:ue(q(d,"marks",p)),group:ue(q(d,"group",p)),inline:ue(q(d,"inline",p)),atom:ue(q(d,"atom",p)),selectable:ue(q(d,"selectable",p)),draggable:ue(q(d,"draggable",p)),code:ue(q(d,"code",p)),whitespace:ue(q(d,"whitespace",p)),linebreakReplacement:ue(q(d,"linebreakReplacement",p)),defining:ue(q(d,"defining",p)),isolating:ue(q(d,"isolating",p)),attrs:Object.fromEntries(h.map(A=>{var P;return[A.name,{default:(P=A==null?void 0:A.attribute)===null||P===void 0?void 0:P.default}]}))}),_=ue(q(d,"parseHTML",p));_&&(g.parseDOM=_.map(A=>rp(A,h)));const S=q(d,"renderHTML",p);S&&(g.toDOM=A=>S({node:A,HTMLAttributes:Ta(A,h)}));const k=q(d,"renderText",p);return k&&(g.toText=k),[d.name,g]})),u=Object.fromEntries(s.map(d=>{const h=r.filter(k=>k.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((k,A)=>{const P=q(A,"extendMarkSchema",p);return{...k,...P?P(d):{}}},{}),g=ip({...y,inclusive:ue(q(d,"inclusive",p)),excludes:ue(q(d,"excludes",p)),group:ue(q(d,"group",p)),spanning:ue(q(d,"spanning",p)),code:ue(q(d,"code",p)),attrs:Object.fromEntries(h.map(k=>{var A;return[k.name,{default:(A=k==null?void 0:k.attribute)===null||A===void 0?void 0:A.default}]}))}),_=ue(q(d,"parseHTML",p));_&&(g.parseDOM=_.map(k=>rp(k,h)));const S=q(d,"renderHTML",p);return S&&(g.toDOM=k=>S({mark:k,HTMLAttributes:Ta(k,h)})),[d.name,g]}));return new Gf({topNode:l,nodes:c,marks:u})}function Oa(n,e){return e.nodes[n]||e.marks[n]||null}function sp(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Aa(n,e){const t=fr.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const zw=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,l,c)=>{var u,d;const h=((d=(u=i.type.spec).toText)===null||d===void 0?void 0:d.call(u,{node:i,pos:s,parent:l,index:c}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-s))}),t};function Ca(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Ys{constructor(e){this.find=e.find,this.handler=e.handler}}const Ww=(n,e)=>{if(Ca(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Qs(n){var e;const{editor:t,from:r,to:i,text:s,rules:l,plugin:c}=n,{view:u}=t;if(u.composing)return!1;const d=u.state.doc.resolve(r);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(y=>y.type.spec.code))return!1;let h=!1;const p=zw(d)+s;return l.forEach(y=>{if(h)return;const g=Ww(p,y.find);if(!g)return;const _=u.state.tr,S=qs({state:u.state,transaction:_}),k={from:r-(g[0].length-s.length),to:i},{commands:A,chain:P,can:L}=new Js({editor:t,state:S});y.handler({state:S,range:k,match:g,commands:A,chain:P,can:L})===null||!_.steps.length||(_.setMeta(c,{transform:_,from:r,to:i,text:s}),u.dispatch(_),h=!0)}),h}function $w(n){const{editor:e,rules:t}=n,r=new mt({state:{init(){return null},apply(i,s,l){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=Aa(D.from(h),l.schema);const{from:p}=u,y=p+h.length;Qs({editor:e,from:p,to:y,text:h,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,l,c){return Qs({editor:e,from:s,to:l,text:c,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Qs({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:l}=i.state.selection;return l?Qs({editor:e,from:l.pos,to:l.pos,text:`
176
+ `))),0,0):H.empty;let p=n.someProp("clipboardTextParser",y=>y(e,i,r,n));if(p)c=p;else{let y=i.marks(),{schema:g}=n.state,_=dr.fromSchema(g);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(S=>{let k=l.appendChild(document.createElement("p"));S&&k.appendChild(_.serializeNode(g.text(S,y)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),l=vv(t),Ri&&wv(l);let d=l&&l.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let p=+h[3];p>0;p--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(c||(c=(n.someProp("clipboardParser")||n.someProp("domParser")||Rn.fromSchema(n.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!yv.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)c=Sv(gh(c,+h[1],+h[2]),h[4]);else if(c=H.maxOpen(_v(c.content,i),!0),c.openStart||c.openEnd){let p=0,y=0;for(let g=c.content.firstChild;p<c.openStart&&!g.type.spec.isolating;p++,g=g.firstChild);for(let g=c.content.lastChild;y<c.openEnd&&!g.type.spec.isolating;y++,g=g.lastChild);c=gh(c,p,y)}return n.someProp("transformPasted",p=>{c=p(c,n)}),c}const yv=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function _v(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,l=[];if(n.forEach(c=>{if(!l)return;let u=i.findWrapping(c.type),d;if(!u)return l=null;if(d=l.length&&s.length&&ph(u,s,c,l[l.length-1],0))l[l.length-1]=d;else{l.length&&(l[l.length-1]=mh(l[l.length-1],s.length));let h=hh(c,u);l.push(h),i=i.matchType(h.type),s=u}}),l)return D.from(l)}return n}function hh(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,D.from(n));return n}function ph(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=ph(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(D.from(hh(t,n,i+1))))}}function mh(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,mh(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(D.empty,!0);return n.copy(t.append(r))}function ca(n,e,t,r,i,s){let l=e<0?n.firstChild:n.lastChild,c=l.content;return n.childCount>1&&(s=0),i<r-1&&(c=ca(c,e,t,r,i+1,s)),i>=t&&(c=e<0?l.contentMatchAt(0).fillBefore(c,s<=i).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(D.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,l.copy(c))}function gh(n,e,t){return e<n.openStart&&(n=new H(ca(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new H(ca(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const yh={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _h=null;function bh(){return _h||(_h=document.implementation.createHTMLDocument("title"))}let ua=null;function bv(n){let e=window.trustedTypes;return e?(ua||(ua=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ua.createHTML(n)):n}function vv(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=bh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&yh[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=bv(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function wv(n){let e=n.querySelectorAll(nt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Sv(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:l}=n;for(let c=r.length-2;c>=0;c-=2){let u=t.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=D.from(u.create(r[c+1],i)),s++,l++}return new H(i,s,l)}const ct={},ut={},kv={touchstart:!0,touchmove:!0};class xv{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ev(n){for(let e in ct){let t=ct[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ov(n,r)&&!da(n,r)&&(n.editable||!(r.type in ut))&&t(n,r)},kv[e]?{passive:!0}:void 0)}at&&n.dom.addEventListener("input",()=>null),fa(n)}function Hn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Tv(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function fa(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>da(n,r))})}function da(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ov(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Av(n,e){!da(n,e)&&ct[e.type]&&(n.editable||!(e.type in ut))&&ct[e.type](n,e)}ut.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wh(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(_n&&nt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),jr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,pr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||gv(n,t)?t.preventDefault():Hn(n,"key")},ut.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ut.keypress=(n,e)=>{let t=e;if(wh(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Rt&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof re)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Vs(n){return{left:n.clientX,top:n.clientY}}function Cv(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ha(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let l=s.depth+1;l>0;l--)if(n.someProp(e,c=>l>s.depth?c(n,t,s.nodeAfter,s.before(l),i,!0):c(n,t,s.node(l),s.before(l),i,!1)))return!0;return!1}function Gr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Mv(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Q.isSelectable(r)?(Gr(n,new Q(t)),!0):!1}function Nv(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Q&&(r=t.node);let s=n.state.doc.resolve(e);for(let l=s.depth+1;l>0;l--){let c=l>s.depth?s.nodeAfter:s.node(l);if(Q.isSelectable(c)){r&&t.$from.depth>0&&l>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(l);break}}return i!=null?(Gr(n,Q.create(n.state.doc,i)),!0):!1}function Iv(n,e,t,r,i){return ha(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Nv(n,t):Mv(n,t))}function Pv(n,e,t,r){return ha(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Rv(n,e,t,r){return ha(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Dv(n,t,r)}function Dv(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Gr(n,re.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(l.inlineContent)Gr(n,re.create(r,c+1,c+1+l.content.size));else if(Q.isSelectable(l))Gr(n,Q.create(r,c));else continue;return!0}}function pa(n){return Hs(n)}const vh=Rt?"metaKey":"ctrlKey";ct.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=pa(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Cv(t,n.input.lastClick)&&!t[vh]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let l=n.posAtCoords(Vs(t));l&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lv(n,l,t,!!r)):(s=="doubleClick"?Pv:Rv)(n,l.pos,l.inside,t)?t.preventDefault():Hn(n,"pointer"))};class Lv{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[vh],this.allowDefault=r.shiftKey;let s,l;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),l=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,l=h.depth?h.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.dom.nodeType==1?u.dom:null;let{selection:d}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof Q&&d.from<=l&&d.to>l)&&(this.mightDrag={node:s,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Hn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>vn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Vs(e))),this.updateAllowDefault(e),this.allowDefault||!t?Hn(this.view,"pointer"):Iv(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||at&&this.mightDrag&&!this.mightDrag.node.isAtom||nt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Gr(this.view,oe.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Hn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Hn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ct.touchstart=n=>{n.input.lastTouch=Date.now(),pa(n),Hn(n,"pointer")},ct.touchmove=n=>{n.input.lastTouch=Date.now(),Hn(n,"pointer")},ct.contextmenu=n=>pa(n);function wh(n,e){return n.composing?!0:at&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Bv=_n?5e3:-1;ut.compositionstart=ut.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof re&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Hs(n,!0),n.markCursor=null;else if(Hs(n,!e.selection.empty),qt&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let l=s<0?i.lastChild:i.childNodes[s-1];if(!l)break;if(l.nodeType==3){let c=n.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else i=l,s=-1}}n.input.composing=!0}Sh(n,Bv)},ut.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Sh(n,20))};function Sh(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Hs(n),e))}function kh(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=zv());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Fv(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Mb(e.focusNode,e.focusOffset),r=Nb(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let l=t.pmViewDesc;if(!(!l||!l.isText(t.nodeValue)))return r}}return t||r}function zv(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Hs(n,e=!1){if(!(_n&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),kh(n),e||n.docView&&n.docView.dirty){let t=ra(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Wv(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const zi=gt&&zn<15||jr&&Lb<604;ct.copy=ut.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=zi?null:t.clipboardData,l=r.content(),{dom:c,text:u}=aa(n,l);s?(t.preventDefault(),s.clearData(),s.setData("text/html",c.innerHTML),s.setData("text/plain",u)):Wv(n,c),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $v(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Vv(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Wi(n,r.value,null,i,e):Wi(n,r.textContent,r.innerHTML,i,e)},50)}function Wi(n,e,t,r,i){let s=dh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",u=>u(n,i,s||H.empty)))return!0;if(!s)return!1;let l=$v(s),c=l?n.state.tr.replaceSelectionWith(l,r):n.state.tr.replaceSelection(s);return n.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function xh(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ut.paste=(n,e)=>{let t=e;if(n.composing&&!_n)return;let r=zi?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Wi(n,xh(r),r.getData("text/html"),i,t)?t.preventDefault():Vv(n,t)};class Eh{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Th=Rt?"altKey":"ctrlKey";ct.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Vs(t)),l;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Q?i.to-1:i.to))){if(r&&r.mightDrag)l=Q.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(l=Q.create(n.state.doc,p.posBefore))}}let c=(l||n.state.selection).content(),{dom:u,text:d,slice:h}=aa(n,c);(!t.dataTransfer.files.length||!nt||Id>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(zi?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",zi||t.dataTransfer.setData("text/plain",d),n.dragging=new Eh(h,!t[Th],l)},ct.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ut.dragover=ut.dragenter=(n,e)=>e.preventDefault(),ut.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Vs(t));if(!i)return;let s=n.state.doc.resolve(i.pos),l=r&&r.slice;l?n.someProp("transformPasted",_=>{l=_(l,n)}):l=dh(n,xh(t.dataTransfer),zi?null:t.dataTransfer.getData("text/html"),!1,s);let c=!!(r&&!t[Th]);if(n.someProp("handleDrop",_=>_(n,t,l||H.empty,c))){t.preventDefault();return}if(!l)return;t.preventDefault();let u=l?md(n.state.doc,s.pos,l):s.pos;u==null&&(u=s.pos);let d=n.state.tr;if(c){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let h=d.mapping.map(u),p=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,y=d.doc;if(p?d.replaceRangeWith(h,h,l.content.firstChild):d.replaceRange(h,h,l),d.doc.eq(y))return;let g=d.doc.resolve(h);if(p&&Q.isSelectable(l.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(l.content.firstChild))d.setSelection(new Q(g));else{let _=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((S,k,A,P)=>_=P),d.setSelection(sa(n,g,d.doc.resolve(_)))}n.focus(),n.dispatch(d.setMeta("uiEvent","drop"))},ct.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&vn(n)},20))},ct.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ct.beforeinput=(n,e)=>{if(nt&&_n&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,pr(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ut)ct[n]=ut[n];function $i(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Us{constructor(e,t){this.toDOM=e,this.spec=t||_r,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:l}=e.mapResult(t.from+i,this.side<0?-1:1);return l?null:new Lt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Us&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$i(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Un{constructor(e,t){this.attrs=e,this.spec=t||_r}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=l?null:new Lt(s,l,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Un&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}static is(e){return e.type instanceof Un}destroy(){}}class ma{constructor(e,t){this.attrs=e,this.spec=t||_r}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let l=e.mapResult(t.to+i,-1);return l.deleted||l.pos<=s.pos?null:new Lt(s.pos-r,l.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ma&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}destroy(){}}class Lt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Lt(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Lt(e,e,new Us(t,r))}static inline(e,t,r,i){return new Lt(e,t,new Un(r,i))}static node(e,t,r,i){return new Lt(e,t,new ma(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Un}get widget(){return this.type instanceof Us}}const Yr=[],_r={};class Be{constructor(e,t){this.local=e.length?e:Yr,this.children=t.length?t:Yr}static create(e,t){return t.length?Ks(t,e,0,_r):rt}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let l=0;l<this.local.length;l++){let c=this.local[l];c.from<=t&&c.to>=e&&(!s||s(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<t&&this.children[l+1]>e){let c=this.children[l]+1;this.children[l+2].findInner(e-c,t-c,r,i+c,s)}}map(e,t,r){return this==rt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||_r)}mapInner(e,t,r,i,s){let l;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,i);u&&u.type.valid(t,u)?(l||(l=[])).push(u):s.onRemove&&s.onRemove(this.local[c].spec)}return this.children.length?Hv(this.children,l||[],e,t,r,i,s):l?new Be(l.sort(br),Yr):rt}add(e,t){return t.length?this==rt?Be.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((c,u)=>{let d=u+r,h;if(h=Ah(t,c,d)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(c,h,d+1):i.splice(s,0,u,u+c.nodeSize,Ks(h,c,d+1,_r)),s+=3}});let l=Oh(s?Ch(t):t,-r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||l.splice(c--,1);return new Be(l.length?this.local.concat(l).sort(br):this.local,i||this.children)}remove(e){return e.length==0||this==rt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let l,c=r[s]+t,u=r[s+1]+t;for(let h=0,p;h<e.length;h++)(p=e[h])&&p.from>c&&p.to<u&&(e[h]=null,(l||(l=[])).push(p));if(!l)continue;r==this.children&&(r=this.children.slice());let d=r[s+2].removeInner(l,c+1);d!=rt?r[s+2]=d:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,l;s<e.length;s++)if(l=e[s])for(let c=0;c<i.length;c++)i[c].eq(l,t)&&(i==this.local&&(i=this.local.slice()),i.splice(c--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Be(i,r):rt}forChild(e,t){if(this==rt)return this;if(t.isLeaf)return Be.empty;let r,i;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let s=e+1,l=s+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<l&&u.to>s&&u.type instanceof Un){let d=Math.max(s,u.from)-s,h=Math.min(l,u.to)-s;d<h&&(i||(i=[])).push(u.copy(d,h))}}if(i){let c=new Be(i.sort(br),Yr);return r?new Kn([c,r]):c}return r||rt}eq(e){if(this==e)return!0;if(!(e instanceof Be)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ga(this.localsInner(e))}localsInner(e){if(this==rt)return Yr;if(e.inlineContent||!this.local.some(Un.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Un||t.push(this.local[r]);return t}forEachSet(e){e(this)}}Be.empty=new Be([],[]),Be.removeOverlap=ga;const rt=Be.empty;class Kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,_r));return Kn.from(r)}forChild(e,t){if(t.isLeaf)return Be.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=rt&&(s instanceof Kn?r=r.concat(s.members):r.push(s))}return Kn.from(r)}eq(e){if(!(e instanceof Kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let l=0;l<s.length;l++)t.push(s[l])}}return t?ga(r?t:t.sort(br)):Yr}static from(e){switch(e.length){case 0:return rt;case 1:return e[0];default:return new Kn(e.every(t=>t instanceof Be)?e:e.reduce((t,r)=>t.concat(r instanceof Be?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Hv(n,e,t,r,i,s,l){let c=n.slice();for(let d=0,h=s;d<t.maps.length;d++){let p=0;t.maps[d].forEach((y,g,_,S)=>{let k=S-_-(g-y);for(let A=0;A<c.length;A+=3){let P=c[A+1];if(P<0||y>P+h-p)continue;let L=c[A]+h-p;g>=L?c[A+1]=y<=L?-2:-1:y>=h&&k&&(c[A]+=k,c[A+1]+=k)}p+=k}),h=t.maps[d].map(h,-1)}let u=!1;for(let d=0;d<c.length;d+=3)if(c[d+1]<0){if(c[d+1]==-2){u=!0,c[d+1]=-1;continue}let h=t.map(n[d]+s),p=h-i;if(p<0||p>=r.content.size){u=!0;continue}let y=t.map(n[d+1]+s,-1),g=y-i,{index:_,offset:S}=r.content.findIndex(p),k=r.maybeChild(_);if(k&&S==p&&S+k.nodeSize==g){let A=c[d+2].mapInner(t,k,h+1,n[d]+s+1,l);A!=rt?(c[d]=p,c[d+1]=g,c[d+2]=A):(c[d+1]=-2,u=!0)}else u=!0}if(u){let d=Uv(c,n,e,t,i,s,l),h=Ks(d,r,0,l);e=h.local;for(let p=0;p<c.length;p+=3)c[p+1]<0&&(c.splice(p,3),p-=3);for(let p=0,y=0;p<h.children.length;p+=3){let g=h.children[p];for(;y<c.length&&c[y]<g;)y+=3;c.splice(y,0,h.children[p],h.children[p+1],h.children[p+2])}}return new Be(e.sort(br),c)}function Oh(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Lt(i.from+e,i.to+e,i.type))}return t}function Uv(n,e,t,r,i,s,l){function c(u,d){for(let h=0;h<u.local.length;h++){let p=u.local[h].map(r,i,d);p?t.push(p):l.onRemove&&l.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)c(u.children[h+2],u.children[h]+d+1)}for(let u=0;u<n.length;u+=3)n[u+1]==-1&&c(n[u+2],e[u]+s+1);return t}function Ah(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,l;s<n.length;s++)(l=n[s])&&l.from>t&&l.to<r&&((i||(i=[])).push(l),n[s]=null);return i}function Ch(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ks(n,e,t,r){let i=[],s=!1;e.forEach((c,u)=>{let d=Ah(n,c,u+t);if(d){s=!0;let h=Ks(d,c,t+u+1,r);h!=rt&&i.push(u,u+c.nodeSize,h)}});let l=Oh(s?Ch(n):n,-t).sort(br);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||(r.onRemove&&r.onRemove(l[c].spec),l.splice(c--,1));return l.length||i.length?new Be(l,i):rt}function br(n,e){return n.from-e.from||n.to-e.to}function ga(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Mh(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Mh(e,i,r.copy(s.from,r.to)));break}}}return e}function Mh(n,e,t){for(;e<n.length&&br(t,n[e])>0;)e++;n.splice(e,0,t)}function ya(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=rt&&e.push(r)}),n.cursorWrapper&&e.push(Be.create(n.state.doc,[n.cursorWrapper.deco])),Kn.from(e)}const Kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jv=gt&&zn<=11;class qv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Jv{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);gt&&zn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),jv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Kv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ih(this.view)){if(this.suppressingSelectionUpdates)return vn(this.view);if(gt&&zn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&hr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Kr(s))t.add(s);for(let s=e.anchorNode;s;s=Kr(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ih(e)&&!this.ignoreSelectionChange(r),s=-1,l=-1,c=!1,u=[];if(e.editable)for(let h=0;h<t.length;h++){let p=this.registerMutation(t[h],u);p&&(s=s<0?p.from:Math.min(p.from,s),l=l<0?p.to:Math.max(p.to,l),p.typeOver&&(c=!0))}if(qt&&u.length){let h=u.filter(p=>p.nodeName=="BR");if(h.length==2){let[p,y]=h;p.parentNode&&p.parentNode.parentNode==y.parentNode?y.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let y of h){let g=y.parentNode;g&&g.nodeName=="LI"&&(!p||Qv(e,p)!=g)&&y.remove()}}}let d=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fs(r)&&(d=ra(e))&&d.eq(oe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,vn(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,l),Gv(e)),this.handleDOMChange(s,l,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||vn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let p=e.addedNodes[h];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(gt&&zn<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:p,nextSibling:y}=e.addedNodes[h];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(s=y)}let l=i&&i.parentNode==e.target?Ye(i)+1:0,c=r.localPosFromDOM(e.target,l,-1),u=s&&s.parentNode==e.target?Ye(s):e.target.childNodes.length,d=r.localPosFromDOM(e.target,u,1);return{from:c,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Nh=new WeakMap,Ih=!1;function Gv(n){if(!Nh.has(n)&&(Nh.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=qt,Ih)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Ih=!0}}function Ph(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,l=n.domAtPos(n.state.selection.anchor);return hr(l.node,l.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Yv(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Ph(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ph(n,t):null}function Qv(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Xv(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:l,to:c}=n.docView.parseRange(e,t),u=n.domSelectionRange(),d,h=u.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(d=[{node:h,offset:u.anchorOffset}],Fs(u)||d.push({node:u.focusNode,offset:u.focusOffset})),nt&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let A=r.childNodes[k-1],P=A.pmViewDesc;if(A.nodeName=="BR"&&!P){s=k;break}if(!P||P.size)break}let p=n.state.doc,y=n.someProp("domParser")||Rn.fromSchema(n.state.schema),g=p.resolve(l),_=null,S=y.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:Zv,context:g});if(d&&d[0].pos!=null){let k=d[0].pos,A=d[1]&&d[1].pos;A==null&&(A=k),_={anchor:k+l,head:A+l}}return{doc:S,sel:_,from:l,to:c}}function Zv(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(at&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||at&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ew=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tw(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let V=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ne=ra(n,V);if(ne&&!n.state.selection.eq(ne)){if(nt&&_n&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Le=>Le(n,pr(13,"Enter"))))return;let ve=n.state.tr.setSelection(ne);V=="pointer"?ve.setMeta("pointer",!0):V=="key"&&ve.scrollIntoView(),s&&ve.setMeta("composition",s),n.dispatch(ve)}return}let l=n.state.doc.resolve(e),c=l.sharedDepth(t);e=l.before(c+1),t=n.state.doc.resolve(t).after(c+1);let u=n.state.selection,d=Xv(n,e,t),h=n.state.doc,p=h.slice(d.from,d.to),y,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(y=n.state.selection.to,g="end"):(y=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let _=iw(p.content,d.doc.content,d.from,y,g);if(_&&n.input.domChangeCount++,(jr&&n.input.lastIOSEnter>Date.now()-225||_n)&&i.some(V=>V.nodeType==1&&!ew.test(V.nodeName))&&(!_||_.endA>=_.endB)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!_)if(r&&u instanceof re&&!u.empty&&u.$head.sameParent(u.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))_={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let V=Rh(n,n.state.doc,d.sel);if(V&&!V.eq(n.state.selection)){let ne=n.state.tr.setSelection(V);s&&ne.setMeta("composition",s),n.dispatch(ne)}}return}n.state.selection.from<n.state.selection.to&&_.start==_.endB&&n.state.selection instanceof re&&(_.start>n.state.selection.from&&_.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?_.start=n.state.selection.from:_.endA<n.state.selection.to&&_.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(_.endB+=n.state.selection.to-_.endA,_.endA=n.state.selection.to)),gt&&zn<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>d.from&&d.doc.textBetween(_.start-d.from-1,_.start-d.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let S=d.doc.resolveNoCache(_.start-d.from),k=d.doc.resolveNoCache(_.endB-d.from),A=h.resolve(_.start),P=S.sameParent(k)&&S.parent.inlineContent&&A.end()>=_.endA,L;if((jr&&n.input.lastIOSEnter>Date.now()-225&&(!P||i.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!P&&S.pos<d.doc.content.size&&!S.sameParent(k)&&(L=oe.findFrom(d.doc.resolve(S.pos+1),1,!0))&&L.head==k.pos)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>_.start&&rw(h,_.start,_.endA,S,k)&&n.someProp("handleKeyDown",V=>V(n,pr(8,"Backspace")))){_n&&nt&&n.domObserver.suppressSelectionUpdates();return}nt&&_.endB==_.start&&(n.input.lastChromeDelete=Date.now()),_n&&!P&&S.start()!=k.start()&&k.parentOffset==0&&S.depth==k.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==_.endA&&(_.endB-=2,k=d.doc.resolveNoCache(_.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(V){return V(n,pr(13,"Enter"))})},20));let B=_.start,W=_.endA,z,J,j;if(P){if(S.pos==k.pos)gt&&zn<=11&&S.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>vn(n),20)),z=n.state.tr.delete(B,W),J=h.resolve(_.start).marksAcross(h.resolve(_.endA));else if(_.endA==_.endB&&(j=nw(S.parent.content.cut(S.parentOffset,k.parentOffset),A.parent.content.cut(A.parentOffset,_.endA-A.start()))))z=n.state.tr,j.type=="add"?z.addMark(B,W,j.mark):z.removeMark(B,W,j.mark);else if(S.parent.child(S.index()).isText&&S.index()==k.index()-(k.textOffset?0:1)){let V=S.parent.textBetween(S.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",ne=>ne(n,B,W,V)))return;z=n.state.tr.insertText(V,B,W)}}if(z||(z=n.state.tr.replace(B,W,d.doc.slice(_.start-d.from,_.endB-d.from))),d.sel){let V=Rh(n,z.doc,d.sel);V&&!(nt&&n.composing&&V.empty&&(_.start!=_.endB||n.input.lastChromeDelete<Date.now()-100)&&(V.head==B||V.head==z.mapping.map(W)-1)||gt&&V.empty&&V.head==B)&&z.setSelection(V)}J&&z.ensureMarks(J),s&&z.setMeta("composition",s),n.dispatch(z.scrollIntoView())}function Rh(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:sa(n,e.resolve(t.anchor),e.resolve(t.head))}function nw(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,l,c,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)c=i[0],l="add",u=h=>h.mark(c.addToSet(h.marks));else if(i.length==0&&s.length==1)c=s[0],l="remove",u=h=>h.mark(c.removeFromSet(h.marks));else return null;let d=[];for(let h=0;h<e.childCount;h++)d.push(u(e.child(h)));if(D.from(d).eq(n))return{mark:c,type:l}}function rw(n,e,t,r,i){if(t-e<=i.pos-r.pos||_a(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let c=s.nodeAfter;return c!=null&&t==e+c.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let l=n.resolve(_a(s,!0,!0));return!l.parent.isTextblock||l.pos>t||_a(l,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function _a(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function iw(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:l,b:c}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let u=Math.max(0,s-Math.min(l,c));r-=l+u-s}if(l<s&&n.size<e.size){let u=r<=s&&r>=l?s-r:0;s-=u,s&&s<e.size&&Dh(e.textBetween(s-1,s+1))&&(s+=u?1:-1),c=s+(c-l),l=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,s&&s<n.size&&Dh(n.textBetween(s-1,s+1))&&(s+=u?1:-1),l=s+(l-c),c=s}return{start:s,endA:l,endB:c}}function Dh(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class sw{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new xv,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Wh),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Fh(this),Bh(this),this.nodeViews=zh(this),this.docView=jd(this.state.doc,Lh(this),ya(this),this.dom,this),this.domObserver=new Jv(this,(r,i,s,l)=>tw(this,r,i,s,l)),this.domObserver.start(),Ev(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Wh),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,l=!1;e.storedMarks&&this.composing&&(kh(this),l=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(c||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=zh(this);lw(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(c||t.handleDOMEvents!=this._props.handleDOMEvents)&&fa(this),this.editable=Fh(this),Bh(this);let u=ya(this),d=Lh(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=s||!this.docView.matchesNode(e.doc,d,u);(p||!e.selection.eq(i.selection))&&(l=!0);let y=h=="preserve"&&l&&this.dom.style.overflowAnchor==null&&zb(this);if(l){this.domObserver.stop();let g=p&&(gt||nt)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ow(i.selection,e.selection);if(p){let _=nt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Fv(this)),(s||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=jd(e.doc,d,u,this.dom,this)),_&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cv(this))?vn(this,g):(nh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&Wb(y)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Q){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pd(this,t.getBoundingClientRect(),e)}else Pd(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Eh(e.slice,e.move,i<0?void 0:Q.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let l=0;l<this.directPlugins.length;l++){let c=this.directPlugins[l].props[e];if(c!=null&&(i=t?t(c):c))return i}let s=this.state.plugins;if(s)for(let l=0;l<s.length;l++){let c=s[l].props[e];if(c!=null&&(i=t?t(c):c))return i}}hasFocus(){if(gt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&$b(this.dom),vn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return jb(this,e)}coordsAtPos(e,t=1){return zd(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Qb(this,t||this.state,e)}pasteHTML(e,t){return Wi(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Wi(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return aa(this,e)}destroy(){this.docView&&(Tv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ya(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ab())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Av(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?at&&this.root.nodeType===11&&Pb(this.dom.ownerDocument)==this.dom&&Yv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Lh(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Lt.node(0,n.state.doc.content.size,e)]}function Bh(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Lt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Fh(n){return!n.someProp("editable",e=>e(n.state)===!1)}function ow(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function zh(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lw(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Wh(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var jn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},js={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},aw=typeof navigator<"u"&&/Mac/.test(navigator.platform),cw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Qe=0;Qe<10;Qe++)jn[48+Qe]=jn[96+Qe]=String(Qe);for(var Qe=1;Qe<=24;Qe++)jn[Qe+111]="F"+Qe;for(var Qe=65;Qe<=90;Qe++)jn[Qe]=String.fromCharCode(Qe+32),js[Qe]=String.fromCharCode(Qe);for(var ba in jn)js.hasOwnProperty(ba)||(js[ba]=jn[ba]);function uw(n){var e=aw&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||cw&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?js:jn)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const fw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function dw(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,l;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))fw?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),l&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function hw(n){let e=Object.create(null);for(let t in n)e[dw(t)]=n[t];return e}function va(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function pw(n){return new mt({props:{handleKeyDown:$h(n)}})}function $h(n){let e=hw(n);return function(t,r){let i=uw(r),s,l=e[va(i,r)];if(l&&l(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let c=e[va(i,r,!1)];if(c&&c(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=jn[r.keyCode])&&s!=i){let c=e[va(s,r)];if(c&&c(t.state,t.dispatch,t))return!0}}return!1}}const wa=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Vh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hh=(n,e,t)=>{let r=Vh(n,t);if(!r)return!1;let i=Sa(r);if(!i){let l=r.blockRange(),c=l&&Wr(l);return c==null?!1:(e&&e(n.tr.lift(l,c).scrollIntoView()),!0)}let s=i.nodeBefore;if(Xh(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Qr(s,"end")||Q.isSelectable(s)))for(let l=r.depth;;l--){let c=Ls(n.doc,r.before(l),r.after(l),H.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=n.tr.step(c);u.setSelection(Qr(s,"end")?oe.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Q.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(l==1||r.node(l-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},mw=(n,e,t)=>{let r=Vh(n,t);if(!r)return!1;let i=Sa(r);return i?Uh(n,i,e):!1},gw=(n,e,t)=>{let r=jh(n,t);if(!r)return!1;let i=ka(r);return i?Uh(n,i,e):!1};function Uh(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let l=e.nodeAfter,c=l,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let d=Ls(n.doc,s,u,H.empty);if(!d||d.from!=s||d instanceof $e&&d.slice.size>=u-s)return!1;if(t){let h=n.tr.step(d);h.setSelection(re.create(h.doc,s)),t(h.scrollIntoView())}return!0}function Qr(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Kh=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Sa(r)}let l=s&&s.nodeBefore;return!l||!Q.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)};function Sa(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function jh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const qh=(n,e,t)=>{let r=jh(n,t);if(!r)return!1;let i=ka(r);if(!i)return!1;let s=i.nodeAfter;if(Xh(n,i,e,1))return!0;if(r.parent.content.size==0&&(Qr(s,"start")||Q.isSelectable(s))){let l=Ls(n.doc,r.before(),r.after(),H.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Qr(s,"start")?oe.findFrom(c.doc.resolve(c.mapping.map(i.pos)),1):Q.create(c.doc,c.mapping.map(i.pos))),e(c.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Jh=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=ka(r)}let l=s&&s.nodeAfter;return!l||!Q.isSelectable(l)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos)).scrollIntoView()),!0)};function ka(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const yw=(n,e)=>{let t=n.selection,r=t instanceof Q,i;if(r){if(t.node.isTextblock||!Bn(n.doc,t.from))return!1;i=t.from}else if(i=Ds(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(Q.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},_w=(n,e)=>{let t=n.selection,r;if(t instanceof Q){if(t.node.isTextblock||!Bn(n.doc,t.to))return!1;r=t.to}else if(r=Ds(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},bw=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Wr(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Gh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
177
+ `).scrollIntoView()),!0)};function xa(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const vw=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),l=xa(i.contentMatchAt(s));if(!l||!i.canReplaceWith(s,s,l))return!1;if(e){let c=t.after(),u=n.tr.replaceWith(c,c,l.createAndFill());u.setSelection(oe.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Yh=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof xt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=xa(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let l=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,c=n.tr.insert(l,s.createAndFill());c.setSelection(re.create(c.doc,l+1)),e(c.scrollIntoView())}return!0},Qh=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(gn(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Wr(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function ww(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Q&&e.selection.node.isBlock)return!r.parentOffset||!gn(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],l,c,u=!1,d=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){u=r.end(g)==r.pos+(r.depth-g),d=r.start(g)==r.pos-(r.depth-g),c=xa(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),s.unshift(u&&c?{type:c}:null),l=g;break}else{if(g==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof re||e.selection instanceof xt)&&h.deleteSelection();let p=h.mapping.map(r.pos),y=gn(h.doc,p,s.length,s);if(y||(s[0]=c?{type:c}:null,y=gn(h.doc,p,s.length,s)),h.split(p,s.length,s),!u&&d&&r.node(l).type!=c){let g=h.mapping.map(r.before(l)),_=h.doc.resolve(g);c&&r.node(l-1).canReplaceWith(_.index(),_.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(l)),c)}return t&&t(h.scrollIntoView()),!0}}const Sw=ww(),kw=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(Q.create(n.doc,i))),!0)};function xw(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Bn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Xh(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,l,c,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&xw(n,e,t))return!0;let d=!u&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(l=(c=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&c.matchType(l[0]||s.type).validEnd){if(t){let g=e.pos+s.nodeSize,_=D.empty;for(let A=l.length-1;A>=0;A--)_=D.from(l[A].create(null,_));_=D.from(i.copy(_));let S=n.tr.step(new Ve(e.pos-1,g,e.pos,g,new H(_,1,0),l.length,!0)),k=S.doc.resolve(g+2*l.length);k.nodeAfter&&k.nodeAfter.type==i.type&&Bn(S.doc,k.pos)&&S.join(k.pos),t(S.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&u?null:oe.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),y=p&&Wr(p);if(y!=null&&y>=e.depth)return t&&t(n.tr.lift(p,y).scrollIntoView()),!0;if(d&&Qr(s,"start",!0)&&Qr(i,"end")){let g=i,_=[];for(;_.push(g),!g.isTextblock;)g=g.lastChild;let S=s,k=1;for(;!S.isTextblock;S=S.firstChild)k++;if(g.canReplace(g.childCount,g.childCount,S.content)){if(t){let A=D.empty;for(let L=_.length-1;L>=0;L--)A=D.from(_[L].copy(A));let P=n.tr.step(new Ve(e.pos-_.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new H(A,_.length,0),0,!0));t(P.scrollIntoView())}return!0}}return!1}function Zh(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(re.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Ew=Zh(-1),Tw=Zh(1);function Ow(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,l=i.blockRange(s),c=l&&Vl(l,n,e);return c?(r&&r(t.tr.wrap(l,c).scrollIntoView()),!0):!1}}function ep(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[s];t.doc.nodesBetween(l,c,(u,d)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(n,e)))if(u.type==n)i=!0;else{let h=t.doc.resolve(d),p=h.index();i=h.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let l=0;l<t.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:u}}=t.selection.ranges[l];s.setBlockType(c,u,n,e)}r(s.scrollIntoView())}return!0}}function Ea(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Ea(wa,Hh,Kh),Ea(wa,qh,Jh),Ea(Gh,Yh,Qh,Sw),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Aw(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,l=i.blockRange(s);if(!l)return!1;let c=r?t.tr:null;return Cw(c,l,n,e)?(r&&r(c.scrollIntoView()),!0):!1}}function Cw(n,e,t,r=null){let i=!1,s=e,l=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=l.resolve(e.start-2);s=new As(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new As(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let c=Vl(s,t,r,e);return c?(n&&Mw(n,e,c,i,t),!0):!1}function Mw(n,e,t,r,i){let s=D.empty;for(let h=t.length-1;h>=0;h--)s=D.from(t[h].type.create(t[h].attrs,s));n.step(new Ve(e.start-(r?2:0),e.end,e.start,e.end,new H(s,0,0),t.length,!0));let l=0;for(let h=0;h<t.length;h++)t[h].type==i&&(l=h+1);let c=t.length-l,u=e.start+t.length-(r?2:0),d=e.parent;for(let h=e.startIndex,p=e.endIndex,y=!0;h<p;h++,y=!1)!y&&gn(n.doc,u,c)&&(n.split(u,c),u+=2*c),u+=d.child(h).nodeSize;return n}function Nw(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,l=>l.childCount>0&&l.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Iw(e,t,n,s):Pw(e,t,s):!0:!1}}function Iw(n,e,t,r){let i=n.tr,s=r.end,l=r.$to.end(r.depth);s<l&&(i.step(new Ve(s-1,l,s,l,new H(D.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new As(i.doc.resolve(r.$from.pos),i.doc.resolve(l),r.depth));const c=Wr(r);if(c==null)return!1;i.lift(r,c);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return Bn(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function Pw(n,e,t){let r=n.tr,i=t.parent;for(let g=t.end,_=t.endIndex-1,S=t.startIndex;_>S;_--)g-=i.child(_).nodeSize,r.delete(g-1,g+1);let s=r.doc.resolve(t.start),l=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let c=t.startIndex==0,u=t.endIndex==i.childCount,d=s.node(-1),h=s.index(-1);if(!d.canReplace(h+(c?0:1),h+1,l.content.append(u?D.empty:D.from(i))))return!1;let p=s.pos,y=p+l.nodeSize;return r.step(new Ve(p-(c?1:0),y+(u?1:0),p+1,y-1,new H((c?D.empty:D.from(i.copy(D.empty))).append(u?D.empty:D.from(i.copy(D.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function Rw(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let l=s.startIndex;if(l==0)return!1;let c=s.parent,u=c.child(l-1);if(u.type!=n)return!1;if(t){let d=u.lastChild&&u.lastChild.type==c.type,h=D.from(d?n.create():null),p=new H(D.from(n.create(null,D.from(c.type.create(null,h)))),d?3:1,0),y=s.start,g=s.end;t(e.tr.step(new Ve(y-(d?3:1),g,y,g,p,1,!0)).scrollIntoView())}return!0}}function qs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class Js{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,l=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>{const p=u(...h)(l);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:l}=i,c=[],u=!!e,d=e||s.tr,h=()=>(!u&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(y=>y===!0)),p={...Object.fromEntries(Object.entries(r).map(([y,g])=>[y,(...S)=>{const k=this.buildProps(d,t),A=g(...S)(k);return c.push(A),p}])),run:h};return p}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,l=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...h)=>d(...h)({...l,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:l}=i,c={tr:e,editor:i,view:l,state:qs({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...h)=>d(...h)(c)]))}};return c}}class Dw{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function q(n,e,t){return n.config[e]===void 0&&n.parent?q(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?q(n.parent,e,t):null}):n.config[e]}function Gs(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function tp(n){const e=[],{nodeExtensions:t,markExtensions:r}=Gs(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:i},u=q(l,"addGlobalAttributes",c);if(!u)return;u().forEach(h=>{h.types.forEach(p=>{Object.entries(h.attributes).forEach(([y,g])=>{e.push({type:p,name:y,attribute:{...s,...g}})})})})}),i.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},u=q(l,"addAttributes",c);if(!u)return;const d=u();Object.entries(d).forEach(([h,p])=>{const y={...s,...p};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:l.name,name:h,attribute:y})})}),e}function He(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Fe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const c=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],d=c.filter(h=>!u.includes(h));r[i]=[...u,...d].join(" ")}else if(i==="style"){const c=s?s.split(";").map(h=>h.trim()).filter(Boolean):[],u=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],d=new Map;u.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),c.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),r[i]=Array.from(d.entries()).map(([h,p])=>`${h}: ${p}`).join("; ")}else r[i]=s}),r},{})}function Ta(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Fe(t,r),{})}function np(n){return typeof n=="function"}function ue(n,e=void 0,...t){return np(n)?e?n.bind(e)(...t):n(...t):n}function Lw(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Bw(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function rp(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(t):Bw(t.getAttribute(l.name));return c==null?s:{...s,[l.name]:c}},{});return{...r,...i}}}}function ip(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Lw(t)?!1:t!=null))}function Fw(n,e){var t;const r=tp(n),{nodeExtensions:i,markExtensions:s}=Gs(n),l=(t=i.find(d=>q(d,"topNode")))===null||t===void 0?void 0:t.name,c=Object.fromEntries(i.map(d=>{const h=r.filter(A=>A.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((A,P)=>{const L=q(P,"extendNodeSchema",p);return{...A,...L?L(d):{}}},{}),g=ip({...y,content:ue(q(d,"content",p)),marks:ue(q(d,"marks",p)),group:ue(q(d,"group",p)),inline:ue(q(d,"inline",p)),atom:ue(q(d,"atom",p)),selectable:ue(q(d,"selectable",p)),draggable:ue(q(d,"draggable",p)),code:ue(q(d,"code",p)),whitespace:ue(q(d,"whitespace",p)),linebreakReplacement:ue(q(d,"linebreakReplacement",p)),defining:ue(q(d,"defining",p)),isolating:ue(q(d,"isolating",p)),attrs:Object.fromEntries(h.map(A=>{var P;return[A.name,{default:(P=A==null?void 0:A.attribute)===null||P===void 0?void 0:P.default}]}))}),_=ue(q(d,"parseHTML",p));_&&(g.parseDOM=_.map(A=>rp(A,h)));const S=q(d,"renderHTML",p);S&&(g.toDOM=A=>S({node:A,HTMLAttributes:Ta(A,h)}));const k=q(d,"renderText",p);return k&&(g.toText=k),[d.name,g]})),u=Object.fromEntries(s.map(d=>{const h=r.filter(k=>k.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((k,A)=>{const P=q(A,"extendMarkSchema",p);return{...k,...P?P(d):{}}},{}),g=ip({...y,inclusive:ue(q(d,"inclusive",p)),excludes:ue(q(d,"excludes",p)),group:ue(q(d,"group",p)),spanning:ue(q(d,"spanning",p)),code:ue(q(d,"code",p)),attrs:Object.fromEntries(h.map(k=>{var A;return[k.name,{default:(A=k==null?void 0:k.attribute)===null||A===void 0?void 0:A.default}]}))}),_=ue(q(d,"parseHTML",p));_&&(g.parseDOM=_.map(k=>rp(k,h)));const S=q(d,"renderHTML",p);return S&&(g.toDOM=k=>S({mark:k,HTMLAttributes:Ta(k,h)})),[d.name,g]}));return new Gf({topNode:l,nodes:c,marks:u})}function Oa(n,e){return e.nodes[n]||e.marks[n]||null}function sp(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Aa(n,e){const t=dr.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const zw=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,l,c)=>{var u,d;const h=((d=(u=i.type.spec).toText)===null||d===void 0?void 0:d.call(u,{node:i,pos:s,parent:l,index:c}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-s))}),t};function Ca(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Ys{constructor(e){this.find=e.find,this.handler=e.handler}}const Ww=(n,e)=>{if(Ca(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Qs(n){var e;const{editor:t,from:r,to:i,text:s,rules:l,plugin:c}=n,{view:u}=t;if(u.composing)return!1;const d=u.state.doc.resolve(r);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(y=>y.type.spec.code))return!1;let h=!1;const p=zw(d)+s;return l.forEach(y=>{if(h)return;const g=Ww(p,y.find);if(!g)return;const _=u.state.tr,S=qs({state:u.state,transaction:_}),k={from:r-(g[0].length-s.length),to:i},{commands:A,chain:P,can:L}=new Js({editor:t,state:S});y.handler({state:S,range:k,match:g,commands:A,chain:P,can:L})===null||!_.steps.length||(_.setMeta(c,{transform:_,from:r,to:i,text:s}),u.dispatch(_),h=!0)}),h}function $w(n){const{editor:e,rules:t}=n,r=new mt({state:{init(){return null},apply(i,s,l){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=Aa(D.from(h),l.schema);const{from:p}=u,y=p+h.length;Qs({editor:e,from:p,to:y,text:h,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,l,c){return Qs({editor:e,from:s,to:l,text:c,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Qs({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:l}=i.state.selection;return l?Qs({editor:e,from:l.pos,to:l.pos,text:`
176
178
  `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Vw(n){return Object.prototype.toString.call(n).slice(8,-1)}function Xs(n){return Vw(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Zs(n,e){const t={...n};return Xs(n)&&Xs(e)&&Object.keys(e).forEach(r=>{Xs(e[r])&&Xs(n[r])?t[r]=Zs(n[r],e[r]):t[r]=e[r]}),t}class Bt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ue(q(this,"addOptions",{name:this.name}))),this.storage=ue(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Bt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Bt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ue(q(t,"addOptions",{name:t.name})),t.storage=ue(q(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===t.name);return u&&r.removeStoredMark(u),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function Hw(n){return typeof n=="number"}class Uw{constructor(e){this.find=e.find,this.handler=e.handler}}const Kw=(n,e,t)=>{if(Ca(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function jw(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:l,dropEvent:c}=n,{commands:u,chain:d,can:h}=new Js({editor:e,state:t}),p=[];return t.doc.nodesBetween(r,i,(g,_)=>{if(!g.isTextblock||g.type.spec.code)return;const S=Math.max(r,_),k=Math.min(i,_+g.content.size),A=g.textBetween(S-_,k-_,void 0,"");Kw(A,s.find,l).forEach(L=>{if(L.index===void 0)return;const B=S+L.index+1,W=B+L[0].length,z={from:t.tr.mapping.map(B),to:t.tr.mapping.map(W)},J=s.handler({state:t,range:z,match:L,commands:u,chain:d,can:h,pasteEvent:l,dropEvent:c});p.push(J)})}),p.every(g=>g!==null)}let eo=null;const qw=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Jw(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:h,from:p,to:y,rule:g,pasteEvt:_})=>{const S=h.tr,k=qs({state:h,transaction:S});if(!(!jw({editor:e,state:k,from:Math.max(p-1,0),to:y.b-1,rule:g,pasteEvent:_,dropEvent:c})||!S.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,S}};return t.map(h=>new mt({view(p){const y=_=>{var S;r=!((S=p.dom.parentElement)===null||S===void 0)&&S.contains(_.target)?p.dom.parentElement:null,r&&(eo=e)},g=()=>{eo&&(eo=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(p,y)=>{if(s=r===p.dom.parentElement,c=y,!s){const g=eo;g&&setTimeout(()=>{const _=g.state.selection;_&&g.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(p,y)=>{var g;const _=(g=y.clipboardData)===null||g===void 0?void 0:g.getData("text/html");return l=y,i=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(p,y,g)=>{const _=p[0],S=_.getMeta("uiEvent")==="paste"&&!i,k=_.getMeta("uiEvent")==="drop"&&!s,A=_.getMeta("applyPasteRules"),P=!!A;if(!S&&!k&&!P)return;if(P){let{text:W}=A;typeof W=="string"?W=W:W=Aa(D.from(W),g.schema);const{from:z}=A,J=z+W.length,j=qw(W);return u({rule:h,state:g,from:z,to:{b:J},pasteEvt:j})}const L=y.doc.content.findDiffStart(g.doc.content),B=y.doc.content.findDiffEnd(g.doc.content);if(!(!Hw(L)||!B||L===B.b))return u({rule:h,state:g,from:L,to:B,pasteEvt:l})}}))}function Gw(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Xr{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Xr.resolve(e),this.schema=Fw(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Xr.sort(Xr.flatten(e)),r=Gw(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=q(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=q(r,"priority")||100,l=q(i,"priority")||100;return s>l?-1:s<l?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Oa(t.name,this.schema)},i=q(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Xr.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(l=>{const c={name:l.name,options:l.options,storage:l.storage,editor:e,type:Oa(l.name,this.schema)},u=[],d=q(l,"addKeyboardShortcuts",c);let h={};if(l.type==="mark"&&q(l,"exitable",c)&&(h.ArrowRight=()=>Bt.handleExit({editor:e,mark:l})),d){const S=Object.fromEntries(Object.entries(d()).map(([k,A])=>[k,()=>A({editor:e})]));h={...h,...S}}const p=pw(h);u.push(p);const y=q(l,"addInputRules",c);sp(l,e.options.enableInputRules)&&y&&r.push(...y());const g=q(l,"addPasteRules",c);sp(l,e.options.enablePasteRules)&&g&&i.push(...g());const _=q(l,"addProseMirrorPlugins",c);if(_){const S=_();u.push(...S)}return u}).flat();return[$w({editor:e,rules:r}),...Jw({editor:e,rules:i}),...s]}get attributes(){return tp(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Gs(this.extensions);return Object.fromEntries(t.filter(r=>!!q(r,"addNodeView")).map(r=>{const i=this.attributes.filter(u=>u.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:He(r.name,this.schema)},l=q(r,"addNodeView",s);if(!l)return[];const c=(u,d,h,p,y)=>{const g=Ta(u,i);return l()({node:u,view:d,getPos:h,decorations:p,innerDecorations:y,editor:e,extension:r,HTMLAttributes:g})};return[r.name,c]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Oa(e.name,this.schema)};e.type==="mark"&&(!((t=ue(q(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=q(e,"onBeforeCreate",r),s=q(e,"onCreate",r),l=q(e,"onUpdate",r),c=q(e,"onSelectionUpdate",r),u=q(e,"onTransaction",r),d=q(e,"onFocus",r),h=q(e,"onBlur",r),p=q(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),d&&this.editor.on("focus",d),h&&this.editor.on("blur",h),p&&this.editor.on("destroy",p)})}}class it{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ue(q(this,"addOptions",{name:this.name}))),this.storage=ue(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new it(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new it({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ue(q(t,"addOptions",{name:t.name})),t.storage=ue(q(t,"addStorage",{name:t.name,options:t.options})),t}}function op(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
177
179
 
178
- `,textSerializers:l={}}=t||{};let c="";return n.nodesBetween(r,i,(u,d,h,p)=>{var y;u.isBlock&&d>r&&(c+=s);const g=l==null?void 0:l[u.type.name];if(g)return h&&(c+=g({node:u,pos:d,parent:h,index:p,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)===null||y===void 0?void 0:y.slice(Math.max(r,d)-d,i-d))}),c}function lp(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Yw=it.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new mt({key:new sn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,l=Math.min(...s.map(h=>h.$from.pos)),c=Math.max(...s.map(h=>h.$to.pos)),u=lp(t);return op(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),Qw=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Xw=(n=!1)=>({commands:e})=>e.setContent("",n),Zw=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:l})=>{n.doc.nodesBetween(s.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:h}=e,p=d.resolve(h.map(u)),y=d.resolve(h.map(u+c.nodeSize)),g=p.blockRange(y);if(!g)return;const _=Wr(g);if(c.type.isTextblock){const{defaultType:S}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(g.start,S)}(_||_===0)&&e.lift(g,_)})}),!0},eS=n=>e=>n(e),tS=()=>({state:n,dispatch:e})=>Yh(n,e),nS=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const l=r.mapping.map(e);return r.insert(l,s.content),r.setSelection(new re(r.doc.resolve(l-1))),!0},rS=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const c=i.before(s),u=i.after(s);n.delete(c,u).scrollIntoView()}return!0}return!1},iS=n=>({tr:e,state:t,dispatch:r})=>{const i=He(n,t.schema),s=e.selection.$anchor;for(let l=s.depth;l>0;l-=1)if(s.node(l).type===i){if(r){const u=s.before(l),d=s.after(l);e.delete(u,d).scrollIntoView()}return!0}return!1},sS=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},oS=()=>({state:n,dispatch:e})=>wa(n,e),lS=()=>({commands:n})=>n.keyboardShortcut("Enter"),aS=()=>({state:n,dispatch:e})=>vw(n,e);function to(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Ca(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function ap(n,e,t={}){return n.find(r=>r.type===e&&to(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function cp(n,e,t={}){return!!ap(n,e,t)}function Ma(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!ap([...i.node.marks],e,t)))return;let l=i.index,c=n.start()+i.offset,u=l+1,d=c+i.node.nodeSize;for(;l>0&&cp([...n.parent.child(l-1).marks],e,t);)l-=1,c-=n.parent.child(l).nodeSize;for(;u<n.parent.childCount&&cp([...n.parent.child(u).marks],e,t);)d+=n.parent.child(u).nodeSize,u+=1;return{from:c,to:d}}function qn(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const cS=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=qn(n,r.schema),{doc:l,selection:c}=t,{$from:u,from:d,to:h}=c;if(i){const p=Ma(u,s,e);if(p&&p.from<=d&&p.to>=h){const y=re.create(l,p.from,p.to);t.setSelection(y)}}return!0},uS=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function up(n){return n instanceof re}function br(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function fp(n,e=null){if(!e)return null;const t=oe.atStart(n),r=oe.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?re.create(n,br(0,i,s),br(n.content.size,i,s)):re.create(n,br(e,i,s),br(e,i,s))}function fS(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Na(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const dS=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const l=()=>{(Na()||fS())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!up(t.state.selection))return l(),!0;const c=fp(i.doc,n)||t.state.selection,u=t.state.selection.eq(c);return s&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},hS=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),pS=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),dp=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&dp(r)}return n};function no(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return dp(t)}function ro(n,e,t){if(n instanceof Pn||n instanceof D)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return D.fromArray(n.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(n);return t.errorOnInvalidContent&&l.check(),l}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),ro("",e,t)}if(i){if(t.errorOnInvalidContent){let l=!1,c="";const u=new Gf({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(l=!0,c=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Rn.fromSchema(u).parseSlice(no(n),t.parseOptions):Rn.fromSchema(u).parse(no(n),t.parseOptions),t.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const s=Rn.fromSchema(e);return t.slice?s.parseSlice(no(n),t.parseOptions).content:s.parse(no(n),t.parseOptions)}return ro("",e,t)}function mS(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof $e||i instanceof Ve))return;const s=n.mapping.maps[r];let l=0;s.forEach((c,u,d,h)=>{l===0&&(l=h)}),n.setSelection(oe.near(n.doc.resolve(l),t))}const gS=n=>!("type"in n),yS=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var l;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let c;try{c=ro(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(l=t.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck})}catch(_){return s.emit("contentError",{editor:s,error:_,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((gS(c)?c:[c]).forEach(_=>{_.check(),h=h?_.isText&&_.marks.length===0:!1,p=p?_.isBlock:!1}),u===d&&p){const{parent:_}=r.doc.resolve(u);_.isTextblock&&!_.type.spec.code&&!_.childCount&&(u-=1,d+=1)}let g;if(h){if(Array.isArray(e))g=e.map(_=>_.text||"").join("");else if(e instanceof D){let _="";e.forEach(S=>{S.text&&(_+=S.text)}),g=_}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else g=c,r.replaceWith(u,d,g);t.updateSelection&&mS(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},_S=()=>({state:n,dispatch:e})=>yw(n,e),bS=()=>({state:n,dispatch:e})=>_w(n,e),vS=()=>({state:n,dispatch:e})=>Hh(n,e),wS=()=>({state:n,dispatch:e})=>qh(n,e),SS=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ds(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},kS=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ds(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},xS=()=>({state:n,dispatch:e})=>mw(n,e),ES=()=>({state:n,dispatch:e})=>gw(n,e);function hp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function TS(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))Na()||hp()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),l&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const OS=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=TS(n).split(/-(?!$)/),l=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,c))});return u==null||u.steps.forEach(d=>{const h=d.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function Vi(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,l=e?He(e,n.schema):null,c=[];n.doc.nodesBetween(r,i,(p,y)=>{if(p.isText)return;const g=Math.max(r,y),_=Math.min(i,y+p.nodeSize);c.push({node:p,from:g,to:_})});const u=i-r,d=c.filter(p=>l?l.name===p.node.type.name:!0).filter(p=>to(p.node.attrs,t,{strict:!1}));return s?!!d.length:d.reduce((p,y)=>p+y.to-y.from,0)>=u}const AS=(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Vi(t,i,e)?bw(t,r):!1},CS=()=>({state:n,dispatch:e})=>Qh(n,e),MS=n=>({state:e,dispatch:t})=>{const r=He(n,e.schema);return Nw(r)(e,t)},NS=()=>({state:n,dispatch:e})=>Gh(n,e);function io(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function pp(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const IS=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,l=null;const c=io(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=He(n,r.schema)),c==="mark"&&(l=qn(n,r.schema)),i&&t.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&t.setNodeMarkup(h,void 0,pp(d.attrs,e)),l&&d.marks.length&&d.marks.forEach(p=>{l===p.type&&t.addMark(h,h+d.nodeSize,l.create(pp(p.attrs,e)))})})}),!0):!1},PS=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),RS=()=>({tr:n,dispatch:e})=>{if(e){const t=new xt(n.doc);n.setSelection(t)}return!0},DS=()=>({state:n,dispatch:e})=>Kh(n,e),LS=()=>({state:n,dispatch:e})=>Jh(n,e),BS=()=>({state:n,dispatch:e})=>kw(n,e),FS=()=>({state:n,dispatch:e})=>Tw(n,e),zS=()=>({state:n,dispatch:e})=>Ew(n,e);function Ia(n,e,t={},r={}){return ro(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const WS=(n,e=!1,t={},r={})=>({editor:i,tr:s,dispatch:l,commands:c})=>{var u,d;const{doc:h}=s;if(t.preserveWhitespace!=="full"){const p=Ia(n,i.schema,t,{errorOnInvalidContent:(u=r.errorOnInvalidContent)!==null&&u!==void 0?u:i.options.enableContentCheck});return l&&s.replaceWith(0,h.content.size,p).setMeta("preventUpdate",!e),!0}return l&&s.setMeta("preventUpdate",!e),c.insertContentAt({from:0,to:h.content.size},n,{parseOptions:t,errorOnInvalidContent:(d=r.errorOnInvalidContent)!==null&&d!==void 0?d:i.options.enableContentCheck})};function mp(n,e){const t=qn(e,n.schema),{from:r,to:i,empty:s}=n.selection,l=[];s?(n.storedMarks&&l.push(...n.storedMarks),l.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===t.name);return c?{...c.attrs}:{}}function $S(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function VS(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Pa(n){return e=>VS(e.$from,n)}function HS(n,e){const t={from:0,to:n.content.size};return op(n,t,e)}function US(n,e){const t=He(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,c=>{s.push(c)});const l=s.reverse().find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function KS(n,e){const t=io(typeof e=="string"?e:e.name,n.schema);return t==="node"?US(n,e):t==="mark"?mp(n,e):{}}function gp(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),l=Ma(s,i.type);l&&r.push({mark:i,...l})}):t.nodesBetween(n,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(l=>({from:s,to:s+i.nodeSize,mark:l})))}),r}function so(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Ra(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?qn(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(p=>s?s.name===p.type.name:!0).find(p=>to(p.attrs,t,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:p,$to:y})=>{const g=p.pos,_=y.pos;n.doc.nodesBetween(g,_,(S,k)=>{if(!S.isText&&!S.marks.length)return;const A=Math.max(g,k),P=Math.min(_,k+S.nodeSize),L=P-A;l+=L,c.push(...S.marks.map(B=>({mark:B,from:A,to:P})))})}),l===0)return!1;const u=c.filter(p=>s?s.name===p.mark.type.name:!0).filter(p=>to(p.mark.attrs,t,{strict:!1})).reduce((p,y)=>p+y.to-y.from,0),d=c.filter(p=>s?p.mark.type!==s&&p.mark.type.excludes(s):!0).reduce((p,y)=>p+y.to-y.from,0);return(u>0?u+d:u)>=l}function jS(n,e,t={}){if(!e)return Vi(n,null,t)||Ra(n,null,t);const r=io(e,n.schema);return r==="node"?Vi(n,e,t):r==="mark"?Ra(n,e,t):!1}function yp(n,e){const{nodeExtensions:t}=Gs(e),r=t.find(l=>l.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ue(q(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Da(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(Da(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function qS(n){return n instanceof Q}function JS(n,e,t){var r;const{selection:i}=e;let s=null;if(up(i)&&(s=i.$cursor),s){const c=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(c)||!c.some(u=>u.type.excludes(t))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(c.pos,u.pos,(h,p,y)=>{if(d)return!1;if(h.isInline){const g=!y||y.type.allowsMarkType(t),_=!!t.isInSet(h.marks)||!h.marks.some(S=>S.type.excludes(t));d=g&&_}return!d}),d})}const GS=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:l,ranges:c}=s,u=qn(n,r.schema);if(i)if(l){const d=mp(r,u);t.addStoredMark(u.create({...d,...e}))}else c.forEach(d=>{const h=d.$from.pos,p=d.$to.pos;r.doc.nodesBetween(h,p,(y,g)=>{const _=Math.max(g,h),S=Math.min(g+y.nodeSize,p);y.marks.find(A=>A.type===u)?y.marks.forEach(A=>{u===A.type&&t.addMark(_,S,u.create({...A.attrs,...e}))}):t.addMark(_,S,u.create(e))})});return JS(r,t,u)},YS=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),QS=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=He(n,t.schema);let l;return t.selection.$anchor.sameParent(t.selection.$head)&&(l=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:c})=>ep(s,{...l,...e})(t)?!0:c.clearNodes()).command(({state:c})=>ep(s,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},XS=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=br(n,0,r.content.size),s=Q.create(r,i);e.setSelection(s)}return!0},ZS=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,l=re.atStart(r).from,c=re.atEnd(r).to,u=br(i,l,c),d=br(s,l,c),h=re.create(r,u,d);e.setSelection(h)}return!0},ek=n=>({state:e,dispatch:t})=>{const r=He(n,e.schema);return Rw(r)(e,t)};function _p(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const tk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:l}=e,{$from:c,$to:u}=s,d=i.extensionManager.attributes,h=so(d,c.node().type.name,c.node().attrs);if(s instanceof Q&&s.node.isBlock)return!c.parentOffset||!gn(l,c.pos)?!1:(r&&(n&&_p(t,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const p=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:$S(c.node(-1).contentMatchAt(c.indexAfter(-1)));let g=p&&y?[{type:y,attrs:h}]:void 0,_=gn(e.doc,e.mapping.map(c.pos),1,g);if(!g&&!_&&gn(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(_=!0,g=y?[{type:y,attrs:h}]:void 0),r){if(_&&(s instanceof re&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,g),y&&!p&&!c.parentOffset&&c.parent.type!==y)){const S=e.mapping.map(c.before()),k=e.doc.resolve(S);c.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}n&&_p(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return _},nk=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var l;const c=He(n,r.schema),{$from:u,$to:d}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(d))return!1;const p=u.node(-1);if(p.type!==c)return!1;const y=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(i){let A=D.empty;const P=u.index(-1)?1:u.index(-2)?2:3;for(let j=u.depth-P;j>=u.depth-3;j-=1)A=D.from(u.node(j).copy(A));const L=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,B={...so(y,u.node().type.name,u.node().attrs),...e},W=((l=c.contentMatch.defaultType)===null||l===void 0?void 0:l.createAndFill(B))||void 0;A=A.append(D.from(c.createAndFill(null,W)||void 0));const z=u.before(u.depth-(P-1));t.replace(z,u.after(-L),new H(A,4-P,0));let J=-1;t.doc.nodesBetween(z,t.doc.content.size,(j,V)=>{if(J>-1)return!1;j.isTextblock&&j.content.size===0&&(J=V+1)}),J>-1&&t.setSelection(re.near(t.doc.resolve(J))),t.scrollIntoView()}return!0}const g=d.pos===u.end()?p.contentMatchAt(0).defaultType:null,_={...so(y,p.type.name,p.attrs),...e},S={...so(y,u.node().type.name,u.node().attrs),...e};t.delete(u.pos,d.pos);const k=g?[{type:c,attrs:_},{type:g,attrs:S}]:[{type:c,attrs:_}];if(!gn(t.doc,u.pos,2))return!1;if(i){const{selection:A,storedMarks:P}=r,{splittableMarks:L}=s.extensionManager,B=P||A.$to.parentOffset&&A.$from.marks();if(t.split(u.pos,2,k).scrollIntoView(),!B||!i)return!0;const W=B.filter(z=>L.includes(z.type.name));t.ensureMarks(W)}return!0},La=(n,e)=>{const t=Pa(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Bn(n.doc,t.pos)&&n.join(t.pos),!0},Ba=(n,e)=>{const t=Pa(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Bn(n.doc,r)&&n.join(r),!0};var rk=Object.freeze({__proto__:null,blur:Qw,clearContent:Xw,clearNodes:Zw,command:eS,createParagraphNear:tS,cut:nS,deleteCurrentNode:rS,deleteNode:iS,deleteRange:sS,deleteSelection:oS,enter:lS,exitCode:aS,extendMarkRange:cS,first:uS,focus:dS,forEach:hS,insertContent:pS,insertContentAt:yS,joinBackward:vS,joinDown:bS,joinForward:wS,joinItemBackward:SS,joinItemForward:kS,joinTextblockBackward:xS,joinTextblockForward:ES,joinUp:_S,keyboardShortcut:OS,lift:AS,liftEmptyBlock:CS,liftListItem:MS,newlineInCode:NS,resetAttributes:IS,scrollIntoView:PS,selectAll:RS,selectNodeBackward:DS,selectNodeForward:LS,selectParentNode:BS,selectTextblockEnd:FS,selectTextblockStart:zS,setContent:WS,setMark:GS,setMeta:YS,setNode:QS,setNodeSelection:XS,setTextSelection:ZS,sinkListItem:ek,splitBlock:tk,splitListItem:nk,toggleList:(n,e,t,r={})=>({editor:i,tr:s,state:l,dispatch:c,chain:u,commands:d,can:h})=>{const{extensions:p,splittableMarks:y}=i.extensionManager,g=He(n,l.schema),_=He(e,l.schema),{selection:S,storedMarks:k}=l,{$from:A,$to:P}=S,L=A.blockRange(P),B=k||S.$to.parentOffset&&S.$from.marks();if(!L)return!1;const W=Pa(z=>yp(z.type.name,p))(S);if(L.depth>=1&&W&&L.depth-W.depth<=1){if(W.node.type===g)return d.liftListItem(_);if(yp(W.node.type.name,p)&&g.validContent(W.node.content)&&c)return u().command(()=>(s.setNodeMarkup(W.pos,g),!0)).command(()=>La(s,g)).command(()=>Ba(s,g)).run()}return!t||!B||!c?u().command(()=>h().wrapInList(g,r)?!0:d.clearNodes()).wrapInList(g,r).command(()=>La(s,g)).command(()=>Ba(s,g)).run():u().command(()=>{const z=h().wrapInList(g,r),J=B.filter(j=>y.includes(j.type.name));return s.ensureMarks(J),z?!0:d.clearNodes()}).wrapInList(g,r).command(()=>La(s,g)).command(()=>Ba(s,g)).run()},toggleMark:(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,l=qn(n,r.schema);return Ra(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:s}):i.setMark(l,e)},toggleNode:(n,e,t={})=>({state:r,commands:i})=>{const s=He(n,r.schema),l=He(e,r.schema),c=Vi(r,s,t);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(l,u):i.setNode(s,{...u,...t})},toggleWrap:(n,e={})=>({state:t,commands:r})=>{const i=He(n,t.schema);return Vi(t,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const l=n.tr,c=s.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(s.text){const u=l.doc.resolve(s.from).marks();l.replaceWith(s.from,s.to,n.schema.text(s.text,u))}else l.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=t,u=qn(n,r.schema),{$from:d,empty:h,ranges:p}=c;if(!i)return!0;if(h&&l){let{from:y,to:g}=c;const _=(s=d.marks().find(k=>k.type===u))===null||s===void 0?void 0:s.attrs,S=Ma(d,u,_);S&&(y=S.from,g=S.to),t.removeMark(y,g,u)}else p.forEach(y=>{t.removeMark(y.$from.pos,y.$to.pos,u)});return t.removeStoredMark(u),!0},updateAttributes:(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,l=null;const c=io(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=He(n,r.schema)),c==="mark"&&(l=qn(n,r.schema)),i&&t.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,y,g,_;t.selection.empty?r.doc.nodesBetween(d,h,(S,k)=>{s&&s===S.type&&(g=Math.max(k,d),_=Math.min(k+S.nodeSize,h),p=k,y=S)}):r.doc.nodesBetween(d,h,(S,k)=>{k<d&&s&&s===S.type&&(g=Math.max(k,d),_=Math.min(k+S.nodeSize,h),p=k,y=S),k>=d&&k<=h&&(s&&s===S.type&&t.setNodeMarkup(k,void 0,{...S.attrs,...e}),l&&S.marks.length&&S.marks.forEach(A=>{if(l===A.type){const P=Math.max(k,d),L=Math.min(k+S.nodeSize,h);t.addMark(P,L,l.create({...A.attrs,...e}))}}))}),y&&(p!==void 0&&t.setNodeMarkup(p,void 0,{...y.attrs,...e}),l&&y.marks.length&&y.marks.forEach(S=>{l===S.type&&t.addMark(g,_,l.create({...S.attrs,...e}))}))}),!0):!1},wrapIn:(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Ow(i,e)(t,r)},wrapInList:(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Aw(i,e)(t,r)}});const ik=it.create({name:"commands",addCommands(){return{...rk}}}),sk=it.create({name:"drop",addProseMirrorPlugins(){return[new mt({key:new sn("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),ok=it.create({name:"editable",addProseMirrorPlugins(){return[new mt({key:new sn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lk=new sn("focusEvents"),ak=it.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new mt({key:lk,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ck=it.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:h,$anchor:p}=u,{pos:y,parent:g}=p,_=p.parent.isTextblock&&y>0?c.doc.resolve(y-1):p,S=_.parent.type.spec.isolating,k=p.pos-p.parentOffset,A=S&&_.parent.childCount===1?k===p.pos:oe.atStart(d).from===y;return!h||!g.type.isTextblock||g.textContent.length||!A||A&&p.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Na()||hp()?s:i},addProseMirrorPlugins(){return[new mt({key:new sn("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(S=>S.getMeta("composition")))return;const r=n.some(S=>S.docChanged)&&!e.doc.eq(t.doc),i=n.some(S=>S.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:l,to:c}=e.selection,u=oe.atStart(e.doc).from,d=oe.atEnd(e.doc).to;if(s||!(l===u&&c===d)||!Da(t.doc))return;const y=t.tr,g=qs({state:t,transaction:y}),{commands:_}=new Js({editor:this.editor,state:g});if(_.clearNodes(),!!y.steps.length)return y}})]}}),uk=it.create({name:"paste",addProseMirrorPlugins(){return[new mt({key:new sn("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),fk=it.create({name:"tabindex",addProseMirrorPlugins(){return[new mt({key:new sn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class vr{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new vr(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new vr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new vr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,l=this.pos+r+(s?0:1),c=this.resolvedPos.doc.resolve(l);if(!i&&c.depth<=this.depth)return;const u=new vr(c,this.editor,i,i?t:null);i&&(u.actualDepth=this.depth+1),e.push(new vr(c,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,l=Object.keys(t);for(let c=0;c<l.length;c+=1){const u=l[c];if(s[u]!==t[u])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(l=>{r&&i.length>0||(l.node.type.name===e&&s.every(u=>t[u]===l.node.attrs[u])&&i.push(l),!(r&&i.length>0)&&(i=i.concat(l.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const dk=`.ProseMirror {
180
+ `,textSerializers:l={}}=t||{};let c="";return n.nodesBetween(r,i,(u,d,h,p)=>{var y;u.isBlock&&d>r&&(c+=s);const g=l==null?void 0:l[u.type.name];if(g)return h&&(c+=g({node:u,pos:d,parent:h,index:p,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)===null||y===void 0?void 0:y.slice(Math.max(r,d)-d,i-d))}),c}function lp(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Yw=it.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new mt({key:new sn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,l=Math.min(...s.map(h=>h.$from.pos)),c=Math.max(...s.map(h=>h.$to.pos)),u=lp(t);return op(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),Qw=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Xw=(n=!1)=>({commands:e})=>e.setContent("",n),Zw=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:l})=>{n.doc.nodesBetween(s.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:h}=e,p=d.resolve(h.map(u)),y=d.resolve(h.map(u+c.nodeSize)),g=p.blockRange(y);if(!g)return;const _=Wr(g);if(c.type.isTextblock){const{defaultType:S}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(g.start,S)}(_||_===0)&&e.lift(g,_)})}),!0},eS=n=>e=>n(e),tS=()=>({state:n,dispatch:e})=>Yh(n,e),nS=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const l=r.mapping.map(e);return r.insert(l,s.content),r.setSelection(new re(r.doc.resolve(l-1))),!0},rS=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const c=i.before(s),u=i.after(s);n.delete(c,u).scrollIntoView()}return!0}return!1},iS=n=>({tr:e,state:t,dispatch:r})=>{const i=He(n,t.schema),s=e.selection.$anchor;for(let l=s.depth;l>0;l-=1)if(s.node(l).type===i){if(r){const u=s.before(l),d=s.after(l);e.delete(u,d).scrollIntoView()}return!0}return!1},sS=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},oS=()=>({state:n,dispatch:e})=>wa(n,e),lS=()=>({commands:n})=>n.keyboardShortcut("Enter"),aS=()=>({state:n,dispatch:e})=>vw(n,e);function to(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Ca(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function ap(n,e,t={}){return n.find(r=>r.type===e&&to(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function cp(n,e,t={}){return!!ap(n,e,t)}function Ma(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!ap([...i.node.marks],e,t)))return;let l=i.index,c=n.start()+i.offset,u=l+1,d=c+i.node.nodeSize;for(;l>0&&cp([...n.parent.child(l-1).marks],e,t);)l-=1,c-=n.parent.child(l).nodeSize;for(;u<n.parent.childCount&&cp([...n.parent.child(u).marks],e,t);)d+=n.parent.child(u).nodeSize,u+=1;return{from:c,to:d}}function qn(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const cS=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=qn(n,r.schema),{doc:l,selection:c}=t,{$from:u,from:d,to:h}=c;if(i){const p=Ma(u,s,e);if(p&&p.from<=d&&p.to>=h){const y=re.create(l,p.from,p.to);t.setSelection(y)}}return!0},uS=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function up(n){return n instanceof re}function vr(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function fp(n,e=null){if(!e)return null;const t=oe.atStart(n),r=oe.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?re.create(n,vr(0,i,s),vr(n.content.size,i,s)):re.create(n,vr(e,i,s),vr(e,i,s))}function fS(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Na(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const dS=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const l=()=>{(Na()||fS())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!up(t.state.selection))return l(),!0;const c=fp(i.doc,n)||t.state.selection,u=t.state.selection.eq(c);return s&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},hS=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),pS=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),dp=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&dp(r)}return n};function no(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return dp(t)}function ro(n,e,t){if(n instanceof Pn||n instanceof D)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return D.fromArray(n.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(n);return t.errorOnInvalidContent&&l.check(),l}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),ro("",e,t)}if(i){if(t.errorOnInvalidContent){let l=!1,c="";const u=new Gf({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(l=!0,c=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Rn.fromSchema(u).parseSlice(no(n),t.parseOptions):Rn.fromSchema(u).parse(no(n),t.parseOptions),t.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const s=Rn.fromSchema(e);return t.slice?s.parseSlice(no(n),t.parseOptions).content:s.parse(no(n),t.parseOptions)}return ro("",e,t)}function mS(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof $e||i instanceof Ve))return;const s=n.mapping.maps[r];let l=0;s.forEach((c,u,d,h)=>{l===0&&(l=h)}),n.setSelection(oe.near(n.doc.resolve(l),t))}const gS=n=>!("type"in n),yS=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var l;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let c;try{c=ro(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(l=t.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck})}catch(_){return s.emit("contentError",{editor:s,error:_,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((gS(c)?c:[c]).forEach(_=>{_.check(),h=h?_.isText&&_.marks.length===0:!1,p=p?_.isBlock:!1}),u===d&&p){const{parent:_}=r.doc.resolve(u);_.isTextblock&&!_.type.spec.code&&!_.childCount&&(u-=1,d+=1)}let g;if(h){if(Array.isArray(e))g=e.map(_=>_.text||"").join("");else if(e instanceof D){let _="";e.forEach(S=>{S.text&&(_+=S.text)}),g=_}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else g=c,r.replaceWith(u,d,g);t.updateSelection&&mS(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},_S=()=>({state:n,dispatch:e})=>yw(n,e),bS=()=>({state:n,dispatch:e})=>_w(n,e),vS=()=>({state:n,dispatch:e})=>Hh(n,e),wS=()=>({state:n,dispatch:e})=>qh(n,e),SS=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ds(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},kS=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ds(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},xS=()=>({state:n,dispatch:e})=>mw(n,e),ES=()=>({state:n,dispatch:e})=>gw(n,e);function hp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function TS(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))Na()||hp()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),l&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const OS=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=TS(n).split(/-(?!$)/),l=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,c))});return u==null||u.steps.forEach(d=>{const h=d.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function Vi(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,l=e?He(e,n.schema):null,c=[];n.doc.nodesBetween(r,i,(p,y)=>{if(p.isText)return;const g=Math.max(r,y),_=Math.min(i,y+p.nodeSize);c.push({node:p,from:g,to:_})});const u=i-r,d=c.filter(p=>l?l.name===p.node.type.name:!0).filter(p=>to(p.node.attrs,t,{strict:!1}));return s?!!d.length:d.reduce((p,y)=>p+y.to-y.from,0)>=u}const AS=(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Vi(t,i,e)?bw(t,r):!1},CS=()=>({state:n,dispatch:e})=>Qh(n,e),MS=n=>({state:e,dispatch:t})=>{const r=He(n,e.schema);return Nw(r)(e,t)},NS=()=>({state:n,dispatch:e})=>Gh(n,e);function io(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function pp(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const IS=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,l=null;const c=io(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=He(n,r.schema)),c==="mark"&&(l=qn(n,r.schema)),i&&t.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&t.setNodeMarkup(h,void 0,pp(d.attrs,e)),l&&d.marks.length&&d.marks.forEach(p=>{l===p.type&&t.addMark(h,h+d.nodeSize,l.create(pp(p.attrs,e)))})})}),!0):!1},PS=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),RS=()=>({tr:n,dispatch:e})=>{if(e){const t=new xt(n.doc);n.setSelection(t)}return!0},DS=()=>({state:n,dispatch:e})=>Kh(n,e),LS=()=>({state:n,dispatch:e})=>Jh(n,e),BS=()=>({state:n,dispatch:e})=>kw(n,e),FS=()=>({state:n,dispatch:e})=>Tw(n,e),zS=()=>({state:n,dispatch:e})=>Ew(n,e);function Ia(n,e,t={},r={}){return ro(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const WS=(n,e=!1,t={},r={})=>({editor:i,tr:s,dispatch:l,commands:c})=>{var u,d;const{doc:h}=s;if(t.preserveWhitespace!=="full"){const p=Ia(n,i.schema,t,{errorOnInvalidContent:(u=r.errorOnInvalidContent)!==null&&u!==void 0?u:i.options.enableContentCheck});return l&&s.replaceWith(0,h.content.size,p).setMeta("preventUpdate",!e),!0}return l&&s.setMeta("preventUpdate",!e),c.insertContentAt({from:0,to:h.content.size},n,{parseOptions:t,errorOnInvalidContent:(d=r.errorOnInvalidContent)!==null&&d!==void 0?d:i.options.enableContentCheck})};function mp(n,e){const t=qn(e,n.schema),{from:r,to:i,empty:s}=n.selection,l=[];s?(n.storedMarks&&l.push(...n.storedMarks),l.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===t.name);return c?{...c.attrs}:{}}function $S(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function VS(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Pa(n){return e=>VS(e.$from,n)}function HS(n,e){const t={from:0,to:n.content.size};return op(n,t,e)}function US(n,e){const t=He(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,c=>{s.push(c)});const l=s.reverse().find(c=>c.type.name===t.name);return l?{...l.attrs}:{}}function KS(n,e){const t=io(typeof e=="string"?e:e.name,n.schema);return t==="node"?US(n,e):t==="mark"?mp(n,e):{}}function gp(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),l=Ma(s,i.type);l&&r.push({mark:i,...l})}):t.nodesBetween(n,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(l=>({from:s,to:s+i.nodeSize,mark:l})))}),r}function so(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Ra(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?qn(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(p=>s?s.name===p.type.name:!0).find(p=>to(p.attrs,t,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:p,$to:y})=>{const g=p.pos,_=y.pos;n.doc.nodesBetween(g,_,(S,k)=>{if(!S.isText&&!S.marks.length)return;const A=Math.max(g,k),P=Math.min(_,k+S.nodeSize),L=P-A;l+=L,c.push(...S.marks.map(B=>({mark:B,from:A,to:P})))})}),l===0)return!1;const u=c.filter(p=>s?s.name===p.mark.type.name:!0).filter(p=>to(p.mark.attrs,t,{strict:!1})).reduce((p,y)=>p+y.to-y.from,0),d=c.filter(p=>s?p.mark.type!==s&&p.mark.type.excludes(s):!0).reduce((p,y)=>p+y.to-y.from,0);return(u>0?u+d:u)>=l}function jS(n,e,t={}){if(!e)return Vi(n,null,t)||Ra(n,null,t);const r=io(e,n.schema);return r==="node"?Vi(n,e,t):r==="mark"?Ra(n,e,t):!1}function yp(n,e){const{nodeExtensions:t}=Gs(e),r=t.find(l=>l.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ue(q(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Da(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(Da(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function qS(n){return n instanceof Q}function JS(n,e,t){var r;const{selection:i}=e;let s=null;if(up(i)&&(s=i.$cursor),s){const c=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(c)||!c.some(u=>u.type.excludes(t))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(c.pos,u.pos,(h,p,y)=>{if(d)return!1;if(h.isInline){const g=!y||y.type.allowsMarkType(t),_=!!t.isInSet(h.marks)||!h.marks.some(S=>S.type.excludes(t));d=g&&_}return!d}),d})}const GS=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:l,ranges:c}=s,u=qn(n,r.schema);if(i)if(l){const d=mp(r,u);t.addStoredMark(u.create({...d,...e}))}else c.forEach(d=>{const h=d.$from.pos,p=d.$to.pos;r.doc.nodesBetween(h,p,(y,g)=>{const _=Math.max(g,h),S=Math.min(g+y.nodeSize,p);y.marks.find(A=>A.type===u)?y.marks.forEach(A=>{u===A.type&&t.addMark(_,S,u.create({...A.attrs,...e}))}):t.addMark(_,S,u.create(e))})});return JS(r,t,u)},YS=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),QS=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=He(n,t.schema);let l;return t.selection.$anchor.sameParent(t.selection.$head)&&(l=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:c})=>ep(s,{...l,...e})(t)?!0:c.clearNodes()).command(({state:c})=>ep(s,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},XS=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=vr(n,0,r.content.size),s=Q.create(r,i);e.setSelection(s)}return!0},ZS=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,l=re.atStart(r).from,c=re.atEnd(r).to,u=vr(i,l,c),d=vr(s,l,c),h=re.create(r,u,d);e.setSelection(h)}return!0},ek=n=>({state:e,dispatch:t})=>{const r=He(n,e.schema);return Rw(r)(e,t)};function _p(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const tk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:l}=e,{$from:c,$to:u}=s,d=i.extensionManager.attributes,h=so(d,c.node().type.name,c.node().attrs);if(s instanceof Q&&s.node.isBlock)return!c.parentOffset||!gn(l,c.pos)?!1:(r&&(n&&_p(t,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const p=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:$S(c.node(-1).contentMatchAt(c.indexAfter(-1)));let g=p&&y?[{type:y,attrs:h}]:void 0,_=gn(e.doc,e.mapping.map(c.pos),1,g);if(!g&&!_&&gn(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(_=!0,g=y?[{type:y,attrs:h}]:void 0),r){if(_&&(s instanceof re&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,g),y&&!p&&!c.parentOffset&&c.parent.type!==y)){const S=e.mapping.map(c.before()),k=e.doc.resolve(S);c.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}n&&_p(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return _},nk=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var l;const c=He(n,r.schema),{$from:u,$to:d}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(d))return!1;const p=u.node(-1);if(p.type!==c)return!1;const y=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(i){let A=D.empty;const P=u.index(-1)?1:u.index(-2)?2:3;for(let j=u.depth-P;j>=u.depth-3;j-=1)A=D.from(u.node(j).copy(A));const L=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,B={...so(y,u.node().type.name,u.node().attrs),...e},W=((l=c.contentMatch.defaultType)===null||l===void 0?void 0:l.createAndFill(B))||void 0;A=A.append(D.from(c.createAndFill(null,W)||void 0));const z=u.before(u.depth-(P-1));t.replace(z,u.after(-L),new H(A,4-P,0));let J=-1;t.doc.nodesBetween(z,t.doc.content.size,(j,V)=>{if(J>-1)return!1;j.isTextblock&&j.content.size===0&&(J=V+1)}),J>-1&&t.setSelection(re.near(t.doc.resolve(J))),t.scrollIntoView()}return!0}const g=d.pos===u.end()?p.contentMatchAt(0).defaultType:null,_={...so(y,p.type.name,p.attrs),...e},S={...so(y,u.node().type.name,u.node().attrs),...e};t.delete(u.pos,d.pos);const k=g?[{type:c,attrs:_},{type:g,attrs:S}]:[{type:c,attrs:_}];if(!gn(t.doc,u.pos,2))return!1;if(i){const{selection:A,storedMarks:P}=r,{splittableMarks:L}=s.extensionManager,B=P||A.$to.parentOffset&&A.$from.marks();if(t.split(u.pos,2,k).scrollIntoView(),!B||!i)return!0;const W=B.filter(z=>L.includes(z.type.name));t.ensureMarks(W)}return!0},La=(n,e)=>{const t=Pa(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Bn(n.doc,t.pos)&&n.join(t.pos),!0},Ba=(n,e)=>{const t=Pa(l=>l.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Bn(n.doc,r)&&n.join(r),!0};var rk=Object.freeze({__proto__:null,blur:Qw,clearContent:Xw,clearNodes:Zw,command:eS,createParagraphNear:tS,cut:nS,deleteCurrentNode:rS,deleteNode:iS,deleteRange:sS,deleteSelection:oS,enter:lS,exitCode:aS,extendMarkRange:cS,first:uS,focus:dS,forEach:hS,insertContent:pS,insertContentAt:yS,joinBackward:vS,joinDown:bS,joinForward:wS,joinItemBackward:SS,joinItemForward:kS,joinTextblockBackward:xS,joinTextblockForward:ES,joinUp:_S,keyboardShortcut:OS,lift:AS,liftEmptyBlock:CS,liftListItem:MS,newlineInCode:NS,resetAttributes:IS,scrollIntoView:PS,selectAll:RS,selectNodeBackward:DS,selectNodeForward:LS,selectParentNode:BS,selectTextblockEnd:FS,selectTextblockStart:zS,setContent:WS,setMark:GS,setMeta:YS,setNode:QS,setNodeSelection:XS,setTextSelection:ZS,sinkListItem:ek,splitBlock:tk,splitListItem:nk,toggleList:(n,e,t,r={})=>({editor:i,tr:s,state:l,dispatch:c,chain:u,commands:d,can:h})=>{const{extensions:p,splittableMarks:y}=i.extensionManager,g=He(n,l.schema),_=He(e,l.schema),{selection:S,storedMarks:k}=l,{$from:A,$to:P}=S,L=A.blockRange(P),B=k||S.$to.parentOffset&&S.$from.marks();if(!L)return!1;const W=Pa(z=>yp(z.type.name,p))(S);if(L.depth>=1&&W&&L.depth-W.depth<=1){if(W.node.type===g)return d.liftListItem(_);if(yp(W.node.type.name,p)&&g.validContent(W.node.content)&&c)return u().command(()=>(s.setNodeMarkup(W.pos,g),!0)).command(()=>La(s,g)).command(()=>Ba(s,g)).run()}return!t||!B||!c?u().command(()=>h().wrapInList(g,r)?!0:d.clearNodes()).wrapInList(g,r).command(()=>La(s,g)).command(()=>Ba(s,g)).run():u().command(()=>{const z=h().wrapInList(g,r),J=B.filter(j=>y.includes(j.type.name));return s.ensureMarks(J),z?!0:d.clearNodes()}).wrapInList(g,r).command(()=>La(s,g)).command(()=>Ba(s,g)).run()},toggleMark:(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,l=qn(n,r.schema);return Ra(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:s}):i.setMark(l,e)},toggleNode:(n,e,t={})=>({state:r,commands:i})=>{const s=He(n,r.schema),l=He(e,r.schema),c=Vi(r,s,t);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(l,u):i.setNode(s,{...u,...t})},toggleWrap:(n,e={})=>({state:t,commands:r})=>{const i=He(n,t.schema);return Vi(t,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const l=n.tr,c=s.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(s.text){const u=l.doc.resolve(s.from).marks();l.replaceWith(s.from,s.to,n.schema.text(s.text,u))}else l.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=t,u=qn(n,r.schema),{$from:d,empty:h,ranges:p}=c;if(!i)return!0;if(h&&l){let{from:y,to:g}=c;const _=(s=d.marks().find(k=>k.type===u))===null||s===void 0?void 0:s.attrs,S=Ma(d,u,_);S&&(y=S.from,g=S.to),t.removeMark(y,g,u)}else p.forEach(y=>{t.removeMark(y.$from.pos,y.$to.pos,u)});return t.removeStoredMark(u),!0},updateAttributes:(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,l=null;const c=io(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=He(n,r.schema)),c==="mark"&&(l=qn(n,r.schema)),i&&t.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,y,g,_;t.selection.empty?r.doc.nodesBetween(d,h,(S,k)=>{s&&s===S.type&&(g=Math.max(k,d),_=Math.min(k+S.nodeSize,h),p=k,y=S)}):r.doc.nodesBetween(d,h,(S,k)=>{k<d&&s&&s===S.type&&(g=Math.max(k,d),_=Math.min(k+S.nodeSize,h),p=k,y=S),k>=d&&k<=h&&(s&&s===S.type&&t.setNodeMarkup(k,void 0,{...S.attrs,...e}),l&&S.marks.length&&S.marks.forEach(A=>{if(l===A.type){const P=Math.max(k,d),L=Math.min(k+S.nodeSize,h);t.addMark(P,L,l.create({...A.attrs,...e}))}}))}),y&&(p!==void 0&&t.setNodeMarkup(p,void 0,{...y.attrs,...e}),l&&y.marks.length&&y.marks.forEach(S=>{l===S.type&&t.addMark(g,_,l.create({...S.attrs,...e}))}))}),!0):!1},wrapIn:(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Ow(i,e)(t,r)},wrapInList:(n,e={})=>({state:t,dispatch:r})=>{const i=He(n,t.schema);return Aw(i,e)(t,r)}});const ik=it.create({name:"commands",addCommands(){return{...rk}}}),sk=it.create({name:"drop",addProseMirrorPlugins(){return[new mt({key:new sn("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),ok=it.create({name:"editable",addProseMirrorPlugins(){return[new mt({key:new sn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lk=new sn("focusEvents"),ak=it.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new mt({key:lk,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ck=it.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:h,$anchor:p}=u,{pos:y,parent:g}=p,_=p.parent.isTextblock&&y>0?c.doc.resolve(y-1):p,S=_.parent.type.spec.isolating,k=p.pos-p.parentOffset,A=S&&_.parent.childCount===1?k===p.pos:oe.atStart(d).from===y;return!h||!g.type.isTextblock||g.textContent.length||!A||A&&p.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Na()||hp()?s:i},addProseMirrorPlugins(){return[new mt({key:new sn("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(S=>S.getMeta("composition")))return;const r=n.some(S=>S.docChanged)&&!e.doc.eq(t.doc),i=n.some(S=>S.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:l,to:c}=e.selection,u=oe.atStart(e.doc).from,d=oe.atEnd(e.doc).to;if(s||!(l===u&&c===d)||!Da(t.doc))return;const y=t.tr,g=qs({state:t,transaction:y}),{commands:_}=new Js({editor:this.editor,state:g});if(_.clearNodes(),!!y.steps.length)return y}})]}}),uk=it.create({name:"paste",addProseMirrorPlugins(){return[new mt({key:new sn("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),fk=it.create({name:"tabindex",addProseMirrorPlugins(){return[new mt({key:new sn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class wr{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new wr(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new wr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new wr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,l=this.pos+r+(s?0:1),c=this.resolvedPos.doc.resolve(l);if(!i&&c.depth<=this.depth)return;const u=new wr(c,this.editor,i,i?t:null);i&&(u.actualDepth=this.depth+1),e.push(new wr(c,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,l=Object.keys(t);for(let c=0;c<l.length;c+=1){const u=l[c];if(s[u]!==t[u])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(l=>{r&&i.length>0||(l.node.type.name===e&&s.every(u=>t[u]===l.node.attrs[u])&&i.push(l),!(r&&i.length>0)&&(i=i.concat(l.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const dk=`.ProseMirror {
179
181
  position: relative;
180
182
  }
181
183
 
@@ -251,7 +253,7 @@ img.ProseMirror-separator {
251
253
  opacity: 0
252
254
  }`;function hk(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}class pk extends Dw{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=hk(dk,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=np(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(s=>{const l=typeof s=="string"?`${s}$`:s.key;r=t.filter(c=>!c.key.startsWith(l))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[ok,Yw.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),ik,ak,ck,fk,sk,uk].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Xr(i,this)}createCommandManager(){this.commandManager=new Js({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Ia(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(l){if(!(l instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(l.message))throw l;this.emit("contentError",{editor:this,error:l,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(c=>c.name!=="collaboration"),this.createExtensionManager()}}),t=Ia(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=fp(t,this.options.autofocus);this.view=new sw(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Ur.create({doc:t,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(l=>{var c;return(c=this.capturedTransaction)===null||c===void 0?void 0:c.step(l)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return KS(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return jS(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Aa(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
253
255
 
254
- `,textSerializers:r={}}=e||{};return HS(this.state.doc,{blockSeparator:t,textSerializers:{...lp(this.schema),...r}})}get isEmpty(){return Da(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new vr(t,this)}get $doc(){return this.$pos(0)}}function wr(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ue(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],c=r[0];if(l){const u=c.search(/\S/),d=t.from+c.indexOf(l),h=d+l.length;if(gp(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(S=>S===n.type&&S!==g.mark.type)).filter(g=>g.to>d).length)return null;h<t.to&&s.delete(h,t.to),d>t.from&&s.delete(t.from+u,d);const y=t.from+u+l.length;s.addMark(t.from+u,y,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function mk(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ue(n.getAttributes,void 0,r)||{},{tr:s}=e,l=t.from;let c=t.to;const u=n.type.create(i);if(r[1]){const d=r[0].lastIndexOf(r[1]);let h=l+d;h>c?h=c:c=h+r[1].length;const p=r[0][r[0].length-1];s.insertText(p,l+r[0].length-1),s.replaceWith(h,c,u)}else if(r[0]){const d=n.type.isInline?l:l-1;s.insert(d,n.type.create(i)).delete(s.mapping.map(l),s.mapping.map(c))}s.scrollIntoView()}})}function Fa(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ue(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function Hi(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ue(n.getAttributes,void 0,r)||{},l=e.tr.delete(t.from,t.to),u=l.doc.resolve(t.from).blockRange(),d=u&&Vl(u,n.type,s);if(!d)return null;if(l.wrap(u,d),n.keepMarks&&n.editor){const{selection:p,storedMarks:y}=e,{splittableMarks:g}=n.editor.extensionManager,_=y||p.$to.parentOffset&&p.$from.marks();if(_){const S=_.filter(k=>g.includes(k.type.name));l.ensureMarks(S)}}if(n.keepAttributes){const p=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(p,s).run()}const h=l.doc.resolve(t.from-1).nodeBefore;h&&h.type===n.type&&Bn(l.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,h))&&l.join(t.from-1)}})}class yt{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ue(q(this,"addOptions",{name:this.name}))),this.storage=ue(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new yt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new yt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ue(q(t,"addOptions",{name:t.name})),t.storage=ue(q(t,"addStorage",{name:t.name,options:t.options})),t}}function Sr(n){return new Uw({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ue(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:l}=e,c=r[r.length-1],u=r[0];let d=t.to;if(c){const h=u.search(/\S/),p=t.from+u.indexOf(c),y=p+c.length;if(gp(t.from,t.to,e.doc).filter(_=>_.mark.type.excluded.find(k=>k===n.type&&k!==_.mark.type)).filter(_=>_.to>p).length)return null;y<t.to&&l.delete(y,t.to),p>t.from&&l.delete(t.from+h,p),d=t.from+h+c.length,l.addMark(t.from+h,d,n.type.create(s||{})),l.removeStoredMark(n.type)}}})}const gk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,yk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,_k=Bt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[wr({find:gk,type:this.type})]},addPasteRules(){return[Sr({find:yk,type:this.type})]}}),bk=Bt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),vk=Bt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),wk=it.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Sk=Bt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function kk(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var za={exports:{}},Wa={};/**
256
+ `,textSerializers:r={}}=e||{};return HS(this.state.doc,{blockSeparator:t,textSerializers:{...lp(this.schema),...r}})}get isEmpty(){return Da(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new wr(t,this)}get $doc(){return this.$pos(0)}}function Sr(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ue(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],c=r[0];if(l){const u=c.search(/\S/),d=t.from+c.indexOf(l),h=d+l.length;if(gp(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(S=>S===n.type&&S!==g.mark.type)).filter(g=>g.to>d).length)return null;h<t.to&&s.delete(h,t.to),d>t.from&&s.delete(t.from+u,d);const y=t.from+u+l.length;s.addMark(t.from+u,y,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function mk(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ue(n.getAttributes,void 0,r)||{},{tr:s}=e,l=t.from;let c=t.to;const u=n.type.create(i);if(r[1]){const d=r[0].lastIndexOf(r[1]);let h=l+d;h>c?h=c:c=h+r[1].length;const p=r[0][r[0].length-1];s.insertText(p,l+r[0].length-1),s.replaceWith(h,c,u)}else if(r[0]){const d=n.type.isInline?l:l-1;s.insert(d,n.type.create(i)).delete(s.mapping.map(l),s.mapping.map(c))}s.scrollIntoView()}})}function Fa(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ue(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function Hi(n){return new Ys({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ue(n.getAttributes,void 0,r)||{},l=e.tr.delete(t.from,t.to),u=l.doc.resolve(t.from).blockRange(),d=u&&Vl(u,n.type,s);if(!d)return null;if(l.wrap(u,d),n.keepMarks&&n.editor){const{selection:p,storedMarks:y}=e,{splittableMarks:g}=n.editor.extensionManager,_=y||p.$to.parentOffset&&p.$from.marks();if(_){const S=_.filter(k=>g.includes(k.type.name));l.ensureMarks(S)}}if(n.keepAttributes){const p=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(p,s).run()}const h=l.doc.resolve(t.from-1).nodeBefore;h&&h.type===n.type&&Bn(l.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,h))&&l.join(t.from-1)}})}class yt{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ue(q(this,"addOptions",{name:this.name}))),this.storage=ue(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new yt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Zs(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new yt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ue(q(t,"addOptions",{name:t.name})),t.storage=ue(q(t,"addStorage",{name:t.name,options:t.options})),t}}function kr(n){return new Uw({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ue(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:l}=e,c=r[r.length-1],u=r[0];let d=t.to;if(c){const h=u.search(/\S/),p=t.from+u.indexOf(c),y=p+c.length;if(gp(t.from,t.to,e.doc).filter(_=>_.mark.type.excluded.find(k=>k===n.type&&k!==_.mark.type)).filter(_=>_.to>p).length)return null;y<t.to&&l.delete(y,t.to),p>t.from&&l.delete(t.from+h,p),d=t.from+h+c.length,l.addMark(t.from+h,d,n.type.create(s||{})),l.removeStoredMark(n.type)}}})}const gk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,yk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,_k=Bt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Sr({find:gk,type:this.type})]},addPasteRules(){return[kr({find:yk,type:this.type})]}}),bk=Bt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),vk=Bt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),wk=it.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Sk=Bt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function kk(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var za={exports:{}},Wa={};/**
255
257
  * @license React
256
258
  * use-sync-external-store-shim.production.min.js
257
259
  *
@@ -283,8 +285,8 @@ img.ProseMirror-separator {
283
285
  *
284
286
  * This source code is licensed under the MIT license found in the
285
287
  * LICENSE file in the root directory of this source tree.
286
- */var Sp;function Dk(){return Sp||(Sp=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=K,e=oo;function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,l=n.useEffect,c=n.useMemo,u=n.useDebugValue;function d(h,p,y,g,_){var S=s(null),k;S.current===null?(k={hasValue:!1,value:null},S.current=k):k=S.current;var A=c(function(){var W=!1,z,J,j=function(Le){if(!W){W=!0,z=Le;var _t=g(Le);if(_!==void 0&&k.hasValue){var Ke=k.value;if(_(Ke,_t))return J=Ke,Ke}return J=_t,_t}var Me=z,ft=J;if(r(Me,Le))return ft;var Gt=g(Le);return _!==void 0&&_(ft,Gt)?ft:(z=Le,J=Gt,Gt)},V=y===void 0?null:y,ne=function(){return j(p())},ve=V===null?void 0:function(){return j(V())};return[ne,ve]},[p,y,g,_]),P=A[0],L=A[1],B=i(h,P,L);return l(function(){k.hasValue=!0,k.value=B},[B]),u(B),B}Ua.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ua}process.env.NODE_ENV==="production"?Va.exports=Rk():Va.exports=Dk();var Lk=Va.exports;const Bk=typeof window<"u"?K.useLayoutEffect:K.useEffect;class Fk{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function zk(n){var e;const[t]=K.useState(()=>new Fk(n.editor)),r=Lk.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:Pk);return Bk(()=>t.watch(n.editor),[n.editor,t]),K.useDebugValue(r),r}const kp=process.env.NODE_ENV!=="production",Ka=typeof window>"u",Wk=Ka||!!(typeof window<"u"&&window.next);class ja{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ka||Wk?(kp&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ka&&kp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)===null||s===void 0?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)===null||s===void 0?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)===null||s===void 0?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)===null||s===void 0?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)===null||s===void 0?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)===null||s===void 0?void 0:s.call(i,...r)}};return new pk(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((i,s)=>{var l;return i===((l=t.extensions)===null||l===void 0?void 0:l[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ja.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function $k(n={},e=[]){const t=K.useRef(n);t.current=n;const[r]=K.useState(()=>new ja(t)),i=oo.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return K.useDebugValue(i),K.useEffect(r.onRender(e)),zk({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&s===0?0:s+1}),i}const xp=K.createContext({editor:null}),Vk=xp.Consumer;function Hk({children:n,slotAfter:e,slotBefore:t,editorContainerProps:r={},...i}){const s=$k(i);return s?K.createElement(xp.Provider,{value:{editor:s}},t,K.createElement(Vk,null,({editor:l})=>K.createElement(Nk,{editor:l,...r})),n,e):null}const Uk=K.createContext({onDragStart:void 0}),Kk=()=>K.useContext(Uk);K.forwardRef((n,e)=>{const{onDragStart:t}=Kk(),r=n.as||"div";return K.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const jk=/^\s*>\s$/,qk=yt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hi({find:jk,type:this.type})]}}),Jk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Gk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Yk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Qk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Xk=Bt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[wr({find:Jk,type:this.type}),wr({find:Yk,type:this.type})]},addPasteRules(){return[Sr({find:Gk,type:this.type}),Sr({find:Qk,type:this.type})]}}),Zk="listItem",Ep="textStyle",Tp=/^\s*([-+*])\s$/,ex=yt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Zk,this.editor.getAttributes(Ep)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Hi({find:Tp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Hi({find:Tp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ep),editor:this.editor})),[n]}}),tx=/(^|[^`])`([^`]+)`(?!`)/,nx=/(^|[^`])`([^`]+)`(?!`)/g,rx=Bt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[wr({find:tx,type:this.type})]},addPasteRules(){return[Sr({find:nx,type:this.type})]}}),ix=/^```([a-z]+)?[\s\n]$/,sx=/^~~~([a-z]+)?[\s\n]$/,ox=yt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(l=>l.startsWith(t)).map(l=>l.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Fe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(`
288
+ */var Sp;function Dk(){return Sp||(Sp=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=K,e=oo;function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,l=n.useEffect,c=n.useMemo,u=n.useDebugValue;function d(h,p,y,g,_){var S=s(null),k;S.current===null?(k={hasValue:!1,value:null},S.current=k):k=S.current;var A=c(function(){var W=!1,z,J,j=function(Le){if(!W){W=!0,z=Le;var _t=g(Le);if(_!==void 0&&k.hasValue){var Ke=k.value;if(_(Ke,_t))return J=Ke,Ke}return J=_t,_t}var Me=z,ft=J;if(r(Me,Le))return ft;var Gt=g(Le);return _!==void 0&&_(ft,Gt)?ft:(z=Le,J=Gt,Gt)},V=y===void 0?null:y,ne=function(){return j(p())},ve=V===null?void 0:function(){return j(V())};return[ne,ve]},[p,y,g,_]),P=A[0],L=A[1],B=i(h,P,L);return l(function(){k.hasValue=!0,k.value=B},[B]),u(B),B}Ua.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ua}process.env.NODE_ENV==="production"?Va.exports=Rk():Va.exports=Dk();var Lk=Va.exports;const Bk=typeof window<"u"?K.useLayoutEffect:K.useEffect;class Fk{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function zk(n){var e;const[t]=K.useState(()=>new Fk(n.editor)),r=Lk.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:Pk);return Bk(()=>t.watch(n.editor),[n.editor,t]),K.useDebugValue(r),r}const kp=process.env.NODE_ENV!=="production",Ka=typeof window>"u",Wk=Ka||!!(typeof window<"u"&&window.next);class ja{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ka||Wk?(kp&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ka&&kp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)===null||s===void 0?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)===null||s===void 0?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)===null||s===void 0?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)===null||s===void 0?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)===null||s===void 0?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)===null||s===void 0?void 0:s.call(i,...r)}};return new pk(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((i,s)=>{var l;return i===((l=t.extensions)===null||l===void 0?void 0:l[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ja.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function $k(n={},e=[]){const t=K.useRef(n);t.current=n;const[r]=K.useState(()=>new ja(t)),i=oo.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return K.useDebugValue(i),K.useEffect(r.onRender(e)),zk({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&s===0?0:s+1}),i}const xp=K.createContext({editor:null}),Vk=xp.Consumer;function Hk({children:n,slotAfter:e,slotBefore:t,editorContainerProps:r={},...i}){const s=$k(i);return s?K.createElement(xp.Provider,{value:{editor:s}},t,K.createElement(Vk,null,({editor:l})=>K.createElement(Nk,{editor:l,...r})),n,e):null}const Uk=K.createContext({onDragStart:void 0}),Kk=()=>K.useContext(Uk);K.forwardRef((n,e)=>{const{onDragStart:t}=Kk(),r=n.as||"div";return K.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const jk=/^\s*>\s$/,qk=yt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hi({find:jk,type:this.type})]}}),Jk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Gk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Yk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Qk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Xk=Bt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Sr({find:Jk,type:this.type}),Sr({find:Yk,type:this.type})]},addPasteRules(){return[kr({find:Gk,type:this.type}),kr({find:Qk,type:this.type})]}}),Zk="listItem",Ep="textStyle",Tp=/^\s*([-+*])\s$/,ex=yt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Zk,this.editor.getAttributes(Ep)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Hi({find:Tp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Hi({find:Tp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ep),editor:this.editor})),[n]}}),tx=/(^|[^`])`([^`]+)`(?!`)/,nx=/(^|[^`])`([^`]+)`(?!`)/g,rx=Bt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Sr({find:tx,type:this.type})]},addPasteRules(){return[kr({find:nx,type:this.type})]}}),ix=/^```([a-z]+)?[\s\n]$/,sx=/^~~~([a-z]+)?[\s\n]$/,ox=yt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(l=>l.startsWith(t)).map(l=>l.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Fe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(`
287
289
 
288
290
  `);return!s||!l?!1:n.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?n.commands.command(({tr:d})=>(d.setSelection(oe.near(r.resolve(c))),!0)):n.commands.exitCode()}}},addInputRules(){return[Fa({find:ix,type:this.type,getAttributes:n=>({language:n[1]})}),Fa({find:sx,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new mt({key:new sn("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!t||!s)return!1;const{tr:l,schema:c}=n.state,u=c.text(t.replace(/\r\n?/g,`
289
291
  `));return l.replaceSelectionWith(this.type.create({language:s},u)),l.selection.$from.parent.type!==this.type&&l.setSelection(re.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),n.dispatch(l),!0}}})]}}),lx=yt.create({name:"doc",topNode:!0,content:"block+"});function ax(n={}){return new mt({view(e){return new cx(e,n)}})}class cx{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=l=>{this[i](l)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let c=e.nodeBefore,u=e.nodeAfter;if(c||u){let d=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(d){let h=d.getBoundingClientRect(),p=c?h.bottom:h.top;c&&u&&(p=(p+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:h.left,right:h.right,top:p-this.width/2,bottom:p+this.width/2}}}}if(!r){let c=this.editorView.coordsAtPos(this.cursorPos);r={left:c.left-this.width/2,right:c.left+this.width/2,top:c.top,bottom:c.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let s,l;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,l=-pageYOffset;else{let c=i.getBoundingClientRect();s=c.left-i.scrollLeft,l=c.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-l+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let l=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=md(this.editorView.state.doc,l,this.editorView.dragging.slice);c!=null&&(l=c)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const ux=it.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ax(this.options)]}});class Ce extends oe{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Ce.valid(r)?new Ce(r):oe.near(r)}content(){return H.empty}eq(e){return e instanceof Ce&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ce(e.resolve(t.pos))}getBookmark(){return new qa(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!fx(e)||!dx(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Ce.valid(e))return e;let i=e.pos,s=null;for(let l=e.depth;;l--){let c=e.node(l);if(t>0?e.indexAfter(l)<c.childCount:e.index(l)>0){s=c.child(t>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;i+=t;let u=e.doc.resolve(i);if(Ce.valid(u))return u}for(;;){let l=t>0?s.firstChild:s.lastChild;if(!l){if(s.isAtom&&!s.isText&&!Q.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=l,i+=t;let c=e.doc.resolve(i);if(Ce.valid(c))return c}return null}}}Ce.prototype.visible=!1,Ce.findFrom=Ce.findGapCursorFrom,oe.jsonID("gapcursor",Ce);class qa{constructor(e){this.pos=e}map(e){return new qa(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ce.valid(t)?new Ce(t):oe.near(t)}}function fx(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function dx(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function hx(){return new mt({props:{decorations:yx,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ce.valid(t)?new Ce(t):null},handleClick:mx,handleKeyDown:px,handleDOMEvents:{beforeinput:gx}}})}const px=$h({ArrowLeft:lo("horiz",-1),ArrowRight:lo("horiz",1),ArrowUp:lo("vert",-1),ArrowDown:lo("vert",1)});function lo(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let l=r.selection,c=e>0?l.$to:l.$from,u=l.empty;if(l instanceof re){if(!s.endOfTextblock(t)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let d=Ce.findGapCursorFrom(c,e,u);return d?(i&&i(r.tr.setSelection(new Ce(d))),!0):!1}}function mx(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ce.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&Q.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ce(r))),!0)}function gx(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let l=r.length-1;l>=0;l--)i=D.from(r[l].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new H(i,0,0));return s.setSelection(re.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function yx(n){if(!(n.selection instanceof Ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Be.create(n.doc,[Lt.widget(n.selection.head,e,{key:"gapcursor"})])}const _x=it.create({name:"gapCursor",addProseMirrorPlugins(){return[hx()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ue(q(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),bx=yt.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Fe(this.options.HTMLAttributes,n)]},renderText(){return`
290
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:h})=>{if(h&&u&&l){const p=u.filter(y=>c.includes(y.type.name));d.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),vx=yt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Fe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Fa({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var ao=200,Ue=function(){};Ue.prototype.append=function(e){return e.length?(e=Ue.from(e),!this.length&&e||e.length<ao&&this.leafAppend(e)||this.length<ao&&e.leafPrepend(this)||this.appendInner(e)):this},Ue.prototype.prepend=function(e){return e.length?Ue.from(e).append(this):this},Ue.prototype.appendInner=function(e){return new wx(this,e)},Ue.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ue.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ue.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ue.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},Ue.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,l){return i.push(e(s,l))},t,r),i},Ue.from=function(e){return e instanceof Ue?e:e&&e.length?new Op(e):Ue.empty};var Op=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,l,c){for(var u=s;u<l;u++)if(i(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,l,c){for(var u=s-1;u>=l;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ao)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ao)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Ue);Ue.empty=new Op([]);var wx=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,l){var c=this.left.length;if(i<c&&this.left.forEachInner(r,i,Math.min(s,c),l)===!1||s>c&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,s)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,l){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(s,c)-c,l+c)===!1||s<c&&this.left.forEachInvertedInner(r,Math.min(i,c),s,l)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Ue);const Sx=500;class Jt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let l=e.tr,c,u,d=[],h=[];return this.items.forEach((p,y)=>{if(!p.step){i||(i=this.remapping(r,y+1),s=i.maps.length),s--,h.push(p);return}if(i){h.push(new an(p.map));let g=p.step.map(i.slice(s)),_;g&&l.maybeStep(g).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],d.push(new an(_,void 0,void 0,d.length+h.length))),s--,_&&i.appendMap(_,s)}else l.maybeStep(p.step);if(p.selection)return c=i?p.selection.map(i.slice(s)):p.selection,u=new Jt(this.items.slice(0,r).append(h.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:l,selection:c}}addTransform(e,t,r,i){let s=[],l=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let p=e.steps[h].invert(e.docs[h]),y=new an(e.mapping.maps[h],p,t),g;(g=u&&u.merge(y))&&(y=g,h?s.pop():c=c.slice(0,c.length-1)),s.push(y),t&&(l++,t=void 0),i||(u=y)}let d=l-r.depth;return d>xx&&(c=kx(c,d),l-=d),new Jt(c.append(s),l)}remapping(e,t){let r=new Ai;return this.items.forEach((i,s)=>{let l=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,l)},e,t),r}addMaps(e){return this.eventCount==0?this:new Jt(this.items.append(e.map(t=>new an(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},i);let u=t;this.items.forEach(y=>{let g=s.getMirror(--u);if(g==null)return;l=Math.min(l,g);let _=s.maps[g];if(y.step){let S=e.steps[g].invert(e.docs[g]),k=y.selection&&y.selection.map(s.slice(u+1,g));k&&c++,r.push(new an(_,S,k))}else r.push(new an(_))},i);let d=[];for(let y=t;y<l;y++)d.push(new an(s.maps[y]));let h=this.items.slice(0,i).append(d).append(r),p=new Jt(h,c);return p.emptyItemCount()>Sx&&(p=p.compress(this.items.length-r.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((l,c)=>{if(c>=e)i.push(l),l.selection&&s++;else if(l.step){let u=l.step.map(t.slice(r)),d=u&&u.getMap();if(r--,d&&t.appendMap(d,r),u){let h=l.selection&&l.selection.map(t.slice(r));h&&s++;let p=new an(d.invert(),u,h),y,g=i.length-1;(y=i.length&&i[g].merge(p))?i[g]=y:i.push(p)}}else l.map&&r--},this.items.length,0),new Jt(Ue.from(i.reverse()),s)}}Jt.empty=new Jt(Ue.empty,0);function kx(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class an{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new an(t.getMap().invert(),t,this.selection)}}}class Jn{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const xx=20;function Ex(n,e,t,r){let i=t.getMeta(kr),s;if(i)return i.historyState;t.getMeta(Ax)&&(n=new Jn(n.done,n.undone,null,0,-1));let l=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(l&&l.getMeta(kr))return l.getMeta(kr).redo?new Jn(n.done.addTransform(t,void 0,r,co(e)),n.undone,Ap(t.mapping.maps),n.prevTime,n.prevComposition):new Jn(n.done,n.undone.addTransform(t,void 0,r,co(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=t.getMeta("composition"),u=n.prevTime==0||!l&&n.prevComposition!=c&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Tx(t,n.prevRanges)),d=l?Ja(n.prevRanges,t.mapping):Ap(t.mapping.maps);return new Jn(n.done.addTransform(t,u?e.selection.getBookmark():void 0,r,co(e)),Jt.empty,d,t.time,c??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Jn(n.done.rebased(t,s),n.undone.rebased(t,s),Ja(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Jn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ja(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Tx(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Ap(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,l)=>e.push(s,l));return e}function Ja(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function Ox(n,e,t){let r=co(e),i=kr.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let l=s.selection.resolve(s.transform.doc),c=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new Jn(t?c:s.remaining,t?s.remaining:c,null,0,-1);return s.transform.setSelection(l).setMeta(kr,{redo:t,historyState:u})}let Ga=!1,Cp=null;function co(n){let e=n.plugins;if(Cp!=e){Ga=!1,Cp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ga=!0;break}}return Ga}const kr=new sn("history"),Ax=new sn("closeHistory");function Cx(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new mt({key:kr,state:{init(){return new Jn(Jt.empty,Jt.empty,null,0,-1)},apply(e,t,r){return Ex(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Np:r=="historyRedo"?Ip:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Mp(n,e){return(t,r)=>{let i=kr.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=Ox(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Np=Mp(!1,!0),Ip=Mp(!0,!0),Mx=it.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Np(n,e),redo:()=>({state:n,dispatch:e})=>Ip(n,e)}},addProseMirrorPlugins(){return[Cx(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Nx=yt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Fe(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:i}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):qS(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:l,dispatch:c})=>{var u;if(c){const{$to:d}=l.selection,h=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?l.setSelection(re.create(l.doc,d.pos+1)):d.nodeAfter.isBlock?l.setSelection(Q.create(l.doc,d.pos)):l.setSelection(re.create(l.doc,d.pos));else{const p=(u=d.parent.type.contentMatch.defaultType)===null||u===void 0?void 0:u.create();p&&(l.insert(h,p),l.setSelection(re.create(l.doc,h+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mk({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ix=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Px=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Lx=Bt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[wr({find:Ix,type:this.type}),wr({find:Rx,type:this.type})]},addPasteRules(){return[Sr({find:Px,type:this.type}),Sr({find:Dx,type:this.type})]}}),Bx=yt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Fe(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Fx="listItem",Pp="textStyle",Rp=/^(\d+)\.\s$/,zx=yt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Fe(this.options.HTMLAttributes,t),0]:["ol",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Fx,this.editor.getAttributes(Pp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Hi({find:Rp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Hi({find:Rp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Pp)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Wx=yt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$x=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Vx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hx=Bt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[wr({find:$x,type:this.type})]},addPasteRules(){return[Sr({find:Vx,type:this.type})]}}),Ux=yt.create({name:"text",group:"inline"}),Kx=it.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(Xk.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(qk.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(ex.configure(this.options.bulletList)),this.options.code!==!1&&n.push(rx.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(ox.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(lx.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(ux.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(_x.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(bx.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(vx.configure(this.options.heading)),this.options.history!==!1&&n.push(Mx.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(Nx.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(Lx.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Bx.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(zx.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(Wx.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Hx.configure(this.options.strike)),this.options.text!==!1&&n.push(Ux.configure(this.options.text)),n}}),jx=({content:n,style:e})=>Y.jsx("div",{style:e,children:Y.jsx(Hk,{editable:!1,extensions:[Kx,Sk,vk,bk,_k,wk.configure({types:["heading","paragraph"]})],content:n})}),Dp=K.createContext({}),qx=()=>{const n=K.useContext(Dp);if(!n)throw new Error("useWellPlayed must be used within a WellPlayedProvider");return n},Jx=({children:n,clientConfig:e,organizationId:t,apiBaseUrl:r})=>{const i=k_(),s=K.useMemo(()=>Pr.createWellPlayedClient({token:(i==null?void 0:i.accessToken)??void 0,organizationId:t,...e,apiBaseUrl:r}),[i==null?void 0:i.accessToken,t,e,r]);return Y.jsx(Uy,{client:s,children:Y.jsx(Dp.Provider,{value:{organizationId:t,apiClient:s},children:n})})},Gx=({children:n,oidcConfig:e,wpAppConfig:t,...r})=>Y.jsx(b_,{...e,configuration:{...t,...e==null?void 0:e.configuration,authority:`https://oauth.warrior.${r.apiBaseUrl??"well-played.gg"}`},children:Y.jsx(Jx,{...r,children:n})});Je.RichTextEditorContent=jx,Je.WellPlayedProvider=Gx,Je.useConnectedPlayer=T_,Je.usePaginatedLoadAll=bl,Je.usePaginatedQuery=u0,Je.usePlayers=Cf,Je.useTournamentStep=N_,Je.useTournamentTeams=Mf,Je.useWellPlayed=qx,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
292
+ `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:h})=>{if(h&&u&&l){const p=u.filter(y=>c.includes(y.type.name));d.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),vx=yt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Fe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Fa({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var ao=200,Ue=function(){};Ue.prototype.append=function(e){return e.length?(e=Ue.from(e),!this.length&&e||e.length<ao&&this.leafAppend(e)||this.length<ao&&e.leafPrepend(this)||this.appendInner(e)):this},Ue.prototype.prepend=function(e){return e.length?Ue.from(e).append(this):this},Ue.prototype.appendInner=function(e){return new wx(this,e)},Ue.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ue.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ue.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ue.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},Ue.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,l){return i.push(e(s,l))},t,r),i},Ue.from=function(e){return e instanceof Ue?e:e&&e.length?new Op(e):Ue.empty};var Op=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,l,c){for(var u=s;u<l;u++)if(i(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,l,c){for(var u=s-1;u>=l;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ao)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ao)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Ue);Ue.empty=new Op([]);var wx=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,l){var c=this.left.length;if(i<c&&this.left.forEachInner(r,i,Math.min(s,c),l)===!1||s>c&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,s)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,l){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(s,c)-c,l+c)===!1||s<c&&this.left.forEachInvertedInner(r,Math.min(i,c),s,l)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Ue);const Sx=500;class Jt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let l=e.tr,c,u,d=[],h=[];return this.items.forEach((p,y)=>{if(!p.step){i||(i=this.remapping(r,y+1),s=i.maps.length),s--,h.push(p);return}if(i){h.push(new an(p.map));let g=p.step.map(i.slice(s)),_;g&&l.maybeStep(g).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],d.push(new an(_,void 0,void 0,d.length+h.length))),s--,_&&i.appendMap(_,s)}else l.maybeStep(p.step);if(p.selection)return c=i?p.selection.map(i.slice(s)):p.selection,u=new Jt(this.items.slice(0,r).append(h.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:l,selection:c}}addTransform(e,t,r,i){let s=[],l=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let p=e.steps[h].invert(e.docs[h]),y=new an(e.mapping.maps[h],p,t),g;(g=u&&u.merge(y))&&(y=g,h?s.pop():c=c.slice(0,c.length-1)),s.push(y),t&&(l++,t=void 0),i||(u=y)}let d=l-r.depth;return d>xx&&(c=kx(c,d),l-=d),new Jt(c.append(s),l)}remapping(e,t){let r=new Ai;return this.items.forEach((i,s)=>{let l=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,l)},e,t),r}addMaps(e){return this.eventCount==0?this:new Jt(this.items.append(e.map(t=>new an(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},i);let u=t;this.items.forEach(y=>{let g=s.getMirror(--u);if(g==null)return;l=Math.min(l,g);let _=s.maps[g];if(y.step){let S=e.steps[g].invert(e.docs[g]),k=y.selection&&y.selection.map(s.slice(u+1,g));k&&c++,r.push(new an(_,S,k))}else r.push(new an(_))},i);let d=[];for(let y=t;y<l;y++)d.push(new an(s.maps[y]));let h=this.items.slice(0,i).append(d).append(r),p=new Jt(h,c);return p.emptyItemCount()>Sx&&(p=p.compress(this.items.length-r.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((l,c)=>{if(c>=e)i.push(l),l.selection&&s++;else if(l.step){let u=l.step.map(t.slice(r)),d=u&&u.getMap();if(r--,d&&t.appendMap(d,r),u){let h=l.selection&&l.selection.map(t.slice(r));h&&s++;let p=new an(d.invert(),u,h),y,g=i.length-1;(y=i.length&&i[g].merge(p))?i[g]=y:i.push(p)}}else l.map&&r--},this.items.length,0),new Jt(Ue.from(i.reverse()),s)}}Jt.empty=new Jt(Ue.empty,0);function kx(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class an{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new an(t.getMap().invert(),t,this.selection)}}}class Jn{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const xx=20;function Ex(n,e,t,r){let i=t.getMeta(xr),s;if(i)return i.historyState;t.getMeta(Ax)&&(n=new Jn(n.done,n.undone,null,0,-1));let l=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(l&&l.getMeta(xr))return l.getMeta(xr).redo?new Jn(n.done.addTransform(t,void 0,r,co(e)),n.undone,Ap(t.mapping.maps),n.prevTime,n.prevComposition):new Jn(n.done,n.undone.addTransform(t,void 0,r,co(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=t.getMeta("composition"),u=n.prevTime==0||!l&&n.prevComposition!=c&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Tx(t,n.prevRanges)),d=l?Ja(n.prevRanges,t.mapping):Ap(t.mapping.maps);return new Jn(n.done.addTransform(t,u?e.selection.getBookmark():void 0,r,co(e)),Jt.empty,d,t.time,c??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Jn(n.done.rebased(t,s),n.undone.rebased(t,s),Ja(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Jn(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ja(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Tx(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Ap(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,l)=>e.push(s,l));return e}function Ja(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function Ox(n,e,t){let r=co(e),i=xr.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let l=s.selection.resolve(s.transform.doc),c=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new Jn(t?c:s.remaining,t?s.remaining:c,null,0,-1);return s.transform.setSelection(l).setMeta(xr,{redo:t,historyState:u})}let Ga=!1,Cp=null;function co(n){let e=n.plugins;if(Cp!=e){Ga=!1,Cp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ga=!0;break}}return Ga}const xr=new sn("history"),Ax=new sn("closeHistory");function Cx(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new mt({key:xr,state:{init(){return new Jn(Jt.empty,Jt.empty,null,0,-1)},apply(e,t,r){return Ex(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Np:r=="historyRedo"?Ip:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Mp(n,e){return(t,r)=>{let i=xr.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=Ox(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Np=Mp(!1,!0),Ip=Mp(!0,!0),Mx=it.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Np(n,e),redo:()=>({state:n,dispatch:e})=>Ip(n,e)}},addProseMirrorPlugins(){return[Cx(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Nx=yt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Fe(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:i}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):qS(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:l,dispatch:c})=>{var u;if(c){const{$to:d}=l.selection,h=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?l.setSelection(re.create(l.doc,d.pos+1)):d.nodeAfter.isBlock?l.setSelection(Q.create(l.doc,d.pos)):l.setSelection(re.create(l.doc,d.pos));else{const p=(u=d.parent.type.contentMatch.defaultType)===null||u===void 0?void 0:u.create();p&&(l.insert(h,p),l.setSelection(re.create(l.doc,h+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mk({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ix=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Px=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Rx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Lx=Bt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Sr({find:Ix,type:this.type}),Sr({find:Rx,type:this.type})]},addPasteRules(){return[kr({find:Px,type:this.type}),kr({find:Dx,type:this.type})]}}),Bx=yt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Fe(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Fx="listItem",Pp="textStyle",Rp=/^(\d+)\.\s$/,zx=yt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Fe(this.options.HTMLAttributes,t),0]:["ol",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Fx,this.editor.getAttributes(Pp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Hi({find:Rp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Hi({find:Rp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Pp)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Wx=yt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$x=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Vx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hx=Bt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Sr({find:$x,type:this.type})]},addPasteRules(){return[kr({find:Vx,type:this.type})]}}),Ux=yt.create({name:"text",group:"inline"}),Kx=it.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(Xk.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(qk.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(ex.configure(this.options.bulletList)),this.options.code!==!1&&n.push(rx.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(ox.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(lx.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(ux.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(_x.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(bx.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(vx.configure(this.options.heading)),this.options.history!==!1&&n.push(Mx.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(Nx.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(Lx.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Bx.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(zx.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(Wx.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Hx.configure(this.options.strike)),this.options.text!==!1&&n.push(Ux.configure(this.options.text)),n}}),jx=({content:n,style:e})=>Y.jsx("div",{style:e,children:Y.jsx(Hk,{editable:!1,extensions:[Kx,Sk,vk,bk,_k,wk.configure({types:["heading","paragraph"]})],content:n})}),Dp=K.createContext({}),qx=()=>{const n=K.useContext(Dp);if(!n)throw new Error("useWellPlayed must be used within a WellPlayedProvider");return n},Jx=({children:n,clientConfig:e,organizationId:t,apiBaseUrl:r,typedClientConfig:i})=>{const s=k_(),l=K.useMemo(()=>sr.createWellPlayedClient({token:(s==null?void 0:s.accessToken)??void 0,organizationId:t,...e,apiBaseUrl:r}),[s==null?void 0:s.accessToken,t,e,r]);return Y.jsx(Uy,{client:l,children:Y.jsx(Dp.Provider,{value:{organizationId:t,apiClient:l,typedClient:sr.createTypedClient({apiBaseUrl:r,organizationId:t,token:(s==null?void 0:s.accessToken)??void 0,...i})},children:n})})},Gx=({children:n,oidcConfig:e,wpAppConfig:t,...r})=>Y.jsx(b_,{...e,configuration:{...t,...e==null?void 0:e.configuration,authority:`https://oauth.warrior.${r.apiBaseUrl??"well-played.gg"}`},children:Y.jsx(Jx,{...r,children:n})});Je.RichTextEditorContent=jx,Je.WellPlayedProvider=Gx,Je.useConnectedPlayer=T_,Je.usePaginatedLoadAll=bl,Je.usePaginatedQuery=u0,Je.usePlayers=Cf,Je.useTournamentStep=N_,Je.useTournamentTeams=Mf,Je.useWellPlayed=qx,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});