@devtable/dashboard 10.3.2 → 10.3.3
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.
- package/dist/dashboard.es.js +7 -1
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -3024,7 +3024,7 @@ class Xo {
|
|
|
3024
3024
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
3025
3025
|
}
|
|
3026
3026
|
}
|
|
3027
|
-
const pc = "10.3.
|
|
3027
|
+
const pc = "10.3.3", bf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3028
3028
|
__proto__: null,
|
|
3029
3029
|
version: pc
|
|
3030
3030
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -11696,6 +11696,12 @@ const mv = {
|
|
|
11696
11696
|
},
|
|
11697
11697
|
"details + details": {
|
|
11698
11698
|
marginTop: "10px"
|
|
11699
|
+
},
|
|
11700
|
+
blockquote: {
|
|
11701
|
+
fontSize: "14px",
|
|
11702
|
+
lineHeight: "32px",
|
|
11703
|
+
color: "#3D3E45",
|
|
11704
|
+
margin: "0 0 14px"
|
|
11699
11705
|
}
|
|
11700
11706
|
};
|
|
11701
11707
|
function Rc(t, e, n) {
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -116,7 +116,7 @@ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(
|
|
|
116
116
|
SELECT count(*) AS total
|
|
117
117
|
FROM ${n}.${e}
|
|
118
118
|
`}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),b.addDisposer(t,ae.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),Pc=b.types.model("DataSourceModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[be.HTTP,be.MySQL,be.Postgresql]),key:b.types.string,config:b.types.frozen(),tables:b.types.optional(Lc,{}),columns:b.types.optional(zc,{}),tableData:b.types.optional(Oc,{}),indexes:b.types.optional($c,{}),table_schema:b.types.optional(b.types.string,""),table_name:b.types.optional(b.types.string,"")}).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=b.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*b.toGenerator(qe.query(t.controllers.tables.signal)({type:t.type,key:t.key,query:t.tables.sql},{}));t.tables.data=v.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!pt.isCancel(r)){t.tables.data={};const a=v.get(r,"message","unkown error");t.tables.error=v.get(r,"response.data.detail.message",a),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:b.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*b.toGenerator(qe.query(t.controllers.columns.signal)({type:t.type,key:t.key,query:t.columns.sql},{})),t.columns.state="idle",t.columns.error=null}catch(r){if(pt.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const a=v.get(r,"message","unkown error");t.columns.error=v.get(r,"response.data.detail.message",a),t.columns.state="error"}}}),loadIndexes:b.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*b.toGenerator(qe.query(t.controllers.indexes.signal)({type:t.type,key:t.key,query:t.indexes.sql},{})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(pt.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const a=v.get(r,"message","unkown error");t.indexes.error=v.get(r,"response.data.detail.message",a),t.indexes.state="error"}}}),loadTableData:b.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.sql},{}));const[{total:a}]=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.countSql},{}));n.total=Number(a),n.state="idle",n.error=null}catch(a){if(pt.isCancel(a))n.state="idle",n.error=null;else{n.data=[];const o=v.get(a,"message","unkown error");n.error=v.get(a,"response.data.detail.message",o),n.state="error"}}})}}).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.columns.sql,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.indexes.sql,t.loadIndexes,{fireImmediately:!1,delay:500})),b.addDisposer(t,ae.reaction(()=>t.tableData.sql,t.loadTableData,{fireImmediately:!1,delay:0}))}})),Bc=b.types.model("DataSourcesModel",{list:b.types.optional(b.types.array(Pc),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function bn(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function Vc(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const Nc=b.types.model("EditorModel",{path:b.types.optional(b.types.frozen(),[]),settings_open:b.types.optional(b.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=b.getRoot(t),{filters:n,views:r,sqlSnippets:a,queries:o}=e;return[{label:"Query Variables",value:"_QUERY_VARS_",_type:"query_variables",Icon:O.IconVariable},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:O.IconCodeDots,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:O.IconFilter,children:[...n.options,bn("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snippets",value:"_SQL_SNIPPETS_",Icon:O.IconCopy,children:[...a.options,bn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:O.IconDatabase,children:[...o.options,bn("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:O.IconBoxMultiple,children:[...r.editorOptions,bn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=Vc(e);n&&t.setPath(n)}})),qc=b.types.model("MockContextModel",{current:b.types.optional(b.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,n){t.current[e]=n}})),Fc=b.types.model("VariableModel",{name:b.types.string,size:b.types.string,weight:b.types.string,color:b.types.union(b.types.model({type:b.types.literal("static"),staticColor:b.types.string}),b.types.model({type:b.types.literal("continuous"),valueRange:b.types.array(b.types.number),colorRange:b.types.array(b.types.string)}),b.types.model({type:b.types.literal("piecewise")})),formatter:b.types.model({output:b.types.enumeration("Output",["number","percent"]),average:b.types.optional(b.types.boolean,!1),mantissa:b.types.number,trimMantissa:b.types.optional(b.types.boolean,!1)}),data_field:b.types.string,aggregation:b.types.union(b.types.model({type:b.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:b.types.frozen()}),b.types.model({type:b.types.literal("quantile"),config:b.types.model({p:b.types.number})}))}).views(t=>({get json(){const{name:e,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:c}=t;return v.cloneDeep({name:e,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:c})}}));class Gc{constructor(e){V(this,"origin");V(this,"copy");this.origin=e,this.copy=b.clone(e),ae.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(e){b.applySnapshot(this.copy,e)}}const Wc=t=>new Gc(t);class Rc{constructor(){V(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const a=this.migrations.filter(c=>c.version>e.from&&c.version<=e.to),o=v.orderBy(a,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return o.reduce((c,u)=>u.handler(c,r),n)}}class ve extends Rc{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,a)=>({version:e,...n(r,a)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),a=v.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await e.setItem(null,o)}async needMigration({configData:e}){const n=await e.getItem(null);return v.get(n,"version",0)<this.VERSION}}var Xe=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t.custom="custom",t))(Xe||{});const ps=["function text({ value }) {"," // your code goes here"," return value","}"].join(`
|
|
119
|
-
`),yr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class $t{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:v.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=v.get(a,e),c=v.get(o,e);l!==c&&n(l,c)},r)}}class br{constructor(e,n,r){V(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new $t(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new $t(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new $t(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(v.values(e).map(n=>this.constructInstance(new $t(this.attachmentStorage,n.id))))}}class hs{constructor(e){V(this,"rootRef");this.rootRef=ae.observable({current:e})}async deleteItem(e){ae.runInAction(()=>{v.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ae.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:v.get(r,"fireImmediately",!1)})}}class jc{constructor(){V(this,"channels",new Map);V(this,"globalChannel",new Ca)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ca;return this.channels.set(e,r),r}}class Yc{constructor(e){V(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new jc,instanceData:new hs(e.viz.conf)};return this.instances.set(e.id,r),r}}function fs(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new hs({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Qc=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),c={...fs(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},u=o.viewRender;return i(u,{context:c,instance:l,...v.omit(t,["panel","vizManager","data"])})},Kc=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),c=e.getOrCreateInstance(n),u={...fs(c,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:u,instance:c,...v.omit(t,["panel","vizManager","data","panelInfoEditor"])})},gs=(t,e)=>{const n=at.bezier(t),r=at.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},vn=t=>{const e=at.bezier(t);return function(n){return e(n/100).hex()}},Uc={type:"interpolation",displayName:"Red / Green",getColor:gs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Xc={type:"interpolation",displayName:"Yellow / Blue",getColor:gs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Jc={type:"interpolation",displayName:"Red",getColor:vn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Zc={type:"interpolation",displayName:"Green",getColor:vn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Hc={type:"interpolation",displayName:"Blue",getColor:vn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},eu={type:"interpolation",displayName:"Orange",getColor:vn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class tu{constructor(e){V(this,"symbol");this.symbol=Symbol(e)}}function st(t){return new tu(t)}class vr{constructor(){V(this,"parent");V(this,"factoryRegistry",new Map);V(this,"instanceRegistry",new Map)}createScoped(){const e=new vr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=v.get(e,"dispose");v.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ms="10.3.2",nu=Object.freeze(Object.defineProperty({__proto__:null,version:ms},Symbol.toStringTag,{value:"Module"}));class ru{constructor(e){V(this,"staticColors",new Map);V(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class iu{constructor(){V(this,"plugins",new Map);V(this,"vizComponents",new Map);V(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}const R=(t,e)=>{const[n,{setFalse:r}]=J.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(c=>{o(c),r()}),t.watchItem(e,c=>{o(c)})));const l=y.useCallback(async c=>{await t.setItem(e,c),o(c)},[t,e]);return{loading:n,value:a,set:l}},xr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function q(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function ot(t,e){var a;const{queryID:n,columnKey:r}=q(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function xn(t,e){const{queryID:n}=q(e);return n?t[n]:[]}function au(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=q(e);return t[r]}ce.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function su({context:t}){const{value:e}=R(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:f}=v.defaults({},e,xr),h=y.useMemo(()=>xn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:q(o),y:q(l),z:q(c)}),[o,l,c]),{min:w,max:_}=y.useMemo(()=>{const M=v.minBy(h,B=>B[C.columnKey]),L=v.maxBy(h,B=>B[C.columnKey]);return{min:v.get(M,C.columnKey),max:v.get(L,C.columnKey)}},[h,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return e?i(Ne,{echarts:ce,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const ys=y.createContext({panel:null,data:{},loading:!1,errors:[]}),wr=ys.Provider;function Ae(){const t=y.useContext(ys);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const ou={fullScreenPanelID:"",setFullScreenPanelID:v.noop},Cr=y.createContext(ou);function bs(){const t=y.useContext(Cr);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},c)=>{const{panel:u}=Ae(),d=y.useMemo(()=>{const f=[...u.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[u.dataFieldOptions]);return i(s.Select,{ref:c,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function lu({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=v.defaults({},e,xr),{control:a,handleSubmit:o,reset:l}=x.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"x_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"xAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"y_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"yAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"z_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"zAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function cu(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class uu extends ve{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:cu(a,r)}})}}const du={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new uu,name:"bar-3d",viewRender:su,configRender:lu,createConfig(){return{version:2,config:v.cloneDeep(xr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function pu({value:t,onChange:e},n){const r=c=>{e({...t,output:c})},a=c=>{const u=c===0?!1:t.trimMantissa;e({...t,mantissa:c,trimMantissa:u})},o=c=>{e({...t,trimMantissa:c.currentTarget.checked})},l=c=>{e({...t,average:c.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:t.average,onChange:l,disabled:t.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",te(123456789).format(t)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",te(1234).format(t)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",te(.1234).format(t)]})]})})]})]})}const Je=y.forwardRef(pu),tt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
119
|
+
`),yr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class $t{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:v.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=v.get(a,e),c=v.get(o,e);l!==c&&n(l,c)},r)}}class br{constructor(e,n,r){V(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new $t(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new $t(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new $t(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(v.values(e).map(n=>this.constructInstance(new $t(this.attachmentStorage,n.id))))}}class hs{constructor(e){V(this,"rootRef");this.rootRef=ae.observable({current:e})}async deleteItem(e){ae.runInAction(()=>{v.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ae.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:v.get(r,"fireImmediately",!1)})}}class jc{constructor(){V(this,"channels",new Map);V(this,"globalChannel",new Ca)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ca;return this.channels.set(e,r),r}}class Yc{constructor(e){V(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new jc,instanceData:new hs(e.viz.conf)};return this.instances.set(e.id,r),r}}function fs(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new hs({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Qc=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),c={...fs(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},u=o.viewRender;return i(u,{context:c,instance:l,...v.omit(t,["panel","vizManager","data"])})},Kc=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),c=e.getOrCreateInstance(n),u={...fs(c,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:u,instance:c,...v.omit(t,["panel","vizManager","data","panelInfoEditor"])})},gs=(t,e)=>{const n=at.bezier(t),r=at.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},vn=t=>{const e=at.bezier(t);return function(n){return e(n/100).hex()}},Uc={type:"interpolation",displayName:"Red / Green",getColor:gs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Xc={type:"interpolation",displayName:"Yellow / Blue",getColor:gs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Jc={type:"interpolation",displayName:"Red",getColor:vn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Zc={type:"interpolation",displayName:"Green",getColor:vn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Hc={type:"interpolation",displayName:"Blue",getColor:vn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},eu={type:"interpolation",displayName:"Orange",getColor:vn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class tu{constructor(e){V(this,"symbol");this.symbol=Symbol(e)}}function st(t){return new tu(t)}class vr{constructor(){V(this,"parent");V(this,"factoryRegistry",new Map);V(this,"instanceRegistry",new Map)}createScoped(){const e=new vr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=v.get(e,"dispose");v.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ms="10.3.3",nu=Object.freeze(Object.defineProperty({__proto__:null,version:ms},Symbol.toStringTag,{value:"Module"}));class ru{constructor(e){V(this,"staticColors",new Map);V(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class iu{constructor(){V(this,"plugins",new Map);V(this,"vizComponents",new Map);V(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}const R=(t,e)=>{const[n,{setFalse:r}]=J.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(c=>{o(c),r()}),t.watchItem(e,c=>{o(c)})));const l=y.useCallback(async c=>{await t.setItem(e,c),o(c)},[t,e]);return{loading:n,value:a,set:l}},xr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function q(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function ot(t,e){var a;const{queryID:n,columnKey:r}=q(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function xn(t,e){const{queryID:n}=q(e);return n?t[n]:[]}function au(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=q(e);return t[r]}ce.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function su({context:t}){const{value:e}=R(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:f}=v.defaults({},e,xr),h=y.useMemo(()=>xn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:q(o),y:q(l),z:q(c)}),[o,l,c]),{min:w,max:_}=y.useMemo(()=>{const M=v.minBy(h,B=>B[C.columnKey]),L=v.maxBy(h,B=>B[C.columnKey]);return{min:v.get(M,C.columnKey),max:v.get(L,C.columnKey)}},[h,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return e?i(Ne,{echarts:ce,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const ys=y.createContext({panel:null,data:{},loading:!1,errors:[]}),wr=ys.Provider;function Ae(){const t=y.useContext(ys);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const ou={fullScreenPanelID:"",setFullScreenPanelID:v.noop},Cr=y.createContext(ou);function bs(){const t=y.useContext(Cr);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},c)=>{const{panel:u}=Ae(),d=y.useMemo(()=>{const f=[...u.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[u.dataFieldOptions]);return i(s.Select,{ref:c,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function lu({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=v.defaults({},e,xr),{control:a,handleSubmit:o,reset:l}=x.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"x_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"xAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"y_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"yAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"z_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"zAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function cu(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class uu extends ve{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:cu(a,r)}})}}const du={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new uu,name:"bar-3d",viewRender:su,configRender:lu,createConfig(){return{version:2,config:v.cloneDeep(xr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function pu({value:t,onChange:e},n){const r=c=>{e({...t,output:c})},a=c=>{const u=c===0?!1:t.trimMantissa;e({...t,mantissa:c,trimMantissa:u})},o=c=>{e({...t,trimMantissa:c.currentTarget.checked})},l=c=>{e({...t,average:c.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:t.average,onChange:l,disabled:t.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",te(123456789).format(t)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",te(1234).format(t)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",te(.1234).format(t)]})]})})]})]})}const Je=y.forwardRef(pu),tt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
120
120
|
`)},vs={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:fu,configRender:hu,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function hu(t){return i(N,{})}function fu(t){return i(s.Text,{children:"Click chart's series"})}const gu=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Cn=y.forwardRef(({sectionTitle:t,value:e,onChange:n},r)=>{const a=o=>l=>{const c=v.cloneDeep(e);v.set(c,o,l),n(c)};return p(s.Stack,{spacing:0,children:[t&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:t,labelPosition:"right",labelProps:{color:"dimmed"}}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:e.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:gu,value:e.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:e.ellipsis,disabled:!0})]})]})}),gt=y.forwardRef(({value:t,onChange:e},n)=>{const r=o=>{e({...t,on_axis:o})},a=o=>{e({...t,in_tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(Cn,{sectionTitle:"Overflow on Axis",value:t.on_axis,onChange:r}),i(Cn,{sectionTitle:"Overflow in Tooltip",value:t.in_tooltip,onChange:a})]})}),Ze={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function mt({overflow:t,width:e}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[t],r=t==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[t];return`
|
|
121
121
|
max-width: ${e}px;
|
|
122
122
|
word-break: ${n};
|
|
@@ -303,7 +303,7 @@ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(
|
|
|
303
303
|
</tbody>
|
|
304
304
|
</table>
|
|
305
305
|
`}}}function Ns({enabled:t,func_content:e}){return(n,r)=>{if(!t)return n;try{return new Function(`return ${e}`)()(n,r)}catch(a){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${a.message}`),n}}}function zg(t){const{overflow:e,format:n,formatter:r,...a}=t.x_axis.axisLabel,o=lt(e.on_axis);return{type:"value",name:t.x_axis.name??"",nameLocation:"middle",nameGap:25,axisTick:{show:!0,alignWithLabel:!0},axisLabel:{...a,...o,formatter:(l,c)=>{let u=l;try{u=te(l).format(n)}catch{}return Ns(r)(u,c)}}}}const $g={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function Lg(t,e){const n=Mg(t,e),r=Tg(t,n),a={xAxis:zg(t),yAxis:{name:t.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5,axisLine:{show:!0}},series:[...n,...r],tooltip:Ag(t),legend:{show:!0,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[4,8,0,140],data:n.map(o=>o.name)}};return v.defaultsDeep({},a,$g)}function An(t,e,n){return 1-(1-t)*(e-1)/(e-n-1)}function Og(t,e,n,r){const{x_axis:a,y_axis:o}=r,l=ht.regressionLinear()(n),{a:c,b:u,rSquared:d}=l;return{name:t,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"red",children:te(u).format({mantissa:2,trimMantissa:!0})}),i(s.Text,{children:"+"}),i(s.Text,{weight:"bold",color:"red",children:te(c).format({mantissa:2,trimMantissa:!0})}),i(s.Text,{children:"×"}),i(s.Text,{children:a.name})]}),rSquared:d,adjustedRSquared:An(d,e.length,1)}}function Pg(t,e,n,r){const{x_axis:a,y_axis:o}=r,{a:l,b:c,rSquared:u}=ht.regressionExp()(n);return{name:t,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"gray",children:l}),i(s.Text,{children:"×"}),p(s.Group,{position:"left",noWrap:!0,spacing:2,children:[i(s.Text,{children:"Math.exp("}),i(s.Text,{weight:"bold",color:"gray",children:c}),i(s.Text,{children:"×"}),i(s.Text,{children:a.name}),i(s.Text,{children:")"})]})]}),rSquared:u,adjustedRSquared:An(u,e.length,1)}}function Bg(t,e,n,r){const{x_axis:a,y_axis:o}=r,{a:l,b:c,rSquared:u}=ht.regressionLog()(n);return{name:t,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"gray",children:l}),i(s.Text,{children:"×"}),p(s.Group,{position:"left",noWrap:!0,spacing:2,children:[i(s.Text,{children:"Math.log("}),i(s.Text,{children:a.name}),i(s.Text,{children:")"}),i(s.Text,{children:"+"}),i(s.Text,{weight:"bold",color:"gray",children:c})]})]}),rSquared:u,adjustedRSquared:An(u,e.length,1)}}function Vg(t,e,n,r){const{x_axis:a,y_axis:o,regression:l}=r,c=ht.regressionPoly().order(l.transform.config.order)(n),{rSquared:u}=c;return console.log(c),{name:t,expression:"",rSquared:u,adjustedRSquared:An(u,e.length,1)}}function qs(t,e,n){const{regression:r,x_axis:a}=n,o=q(a.data_key),l=q(r.y_axis_data_key),c=e.map(u=>[u[o.columnKey],u[l.columnKey]]);return r.transform.config.method==="linear"?Og(t,e,c,n):r.transform.config.method==="exponential"?Pg(t,e,c,n):r.transform.config.method==="logarithmic"?Bg(t,e,c,n):r.transform.config.method==="polynomial"?Vg(t,e,c,n):{name:t,expression:"",rSquared:0,adjustedRSquared:0}}function Ng(t,e){if(!e)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!e.regression.group_by_key)return[qs("",t,e)];const n=q(e.regression.group_by_key),r=v.groupBy(t,n.columnKey);return Object.entries(r).map(([a,o])=>qs(a,o,e))}const qg={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Fs({desc:t}){const{expression:e,rSquared:n,adjustedRSquared:r}=t;return e?i(s.Table,{fontSize:14,sx:qg,children:p("tbody",{children:[i("tr",{children:i("td",{colSpan:2,children:i(s.Text,{align:"center",children:e})})}),p("tr",{children:[i("td",{children:"R-Sq"}),i("td",{style:{textAlign:"right"},children:te(n).format({output:"percent",mantissa:1})})]}),p("tr",{children:[i("td",{children:"R-Sq(Adjusted)"}),i("td",{style:{textAlign:"right"},children:te(r).format({output:"percent",mantissa:1})})]})]})}):i(s.Text,{children:"Unavailable for this regression method"})}function Fg({conf:t,queryData:e}){var r;const n=y.useMemo(()=>Ng(e,t),[t,e]);return t.regression.group_by_key?(console.log(n),p(s.Tabs,{defaultValue:(r=n[0])==null?void 0:r.name,color:"gray",children:[i(s.Tabs.List,{grow:!0,children:n.map(a=>i(s.Tabs.Tab,{value:a.name,children:a.name},a.name))}),n.map(a=>i(s.Tabs.Panel,{value:a.name,children:i(Fs,{desc:a})},a.name))]})):i(Fs,{desc:n[0]})}function Gg({conf:t,queryData:e}){return p(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[i(s.HoverCard.Target,{children:i(s.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:i(O.IconInfoCircle,{size:14}),children:"Regression Info"})}),i(s.HoverCard.Dropdown,{children:i(Fe,{children:i(Fg,{conf:t,queryData:e})})})]})}function Wg(t){return i(s.Group,{position:"apart",sx:{position:"absolute",top:0,left:0,height:"22px",zIndex:1},children:i(Gg,{...t})})}const zn={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
306
|
-
`)},qr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:{...zn}}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};ce.use([G.DataZoomComponent,he.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Rg({context:t}){const{value:e}=R(t.instanceData,"config"),{width:n,height:r}=t.viewport,a=y.useMemo(()=>{var m;const u=t.data,d=e==null?void 0:e.x_axis.data_key,f=(m=e==null?void 0:e.regression)==null?void 0:m.y_axis_data_key;if(!d||!f)return[];const h=q(d),g=q(f);return u[h.queryID].map(C=>typeof C[g.columnKey]=="number"?C:{...C,[g.columnKey]:Number(C[g.columnKey])})},[t.data,e==null?void 0:e.regression.y_axis_data_key]),o=y.useMemo(()=>Lg(v.defaultsDeep({},e,qr),a),[e,a]),l=y.useRef(null),c=u=>{l.current=u};return!n||!r||!e?null:p(s.Box,{sx:{position:"relative"},children:[i(Wg,{conf:e,queryData:a}),i(Ne,{echarts:ce,onChartReady:c,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})]})}const jg=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function Yg({control:t,watch:e}){e("regression");const n=e("regression.transform.config.method"),r=e("regression.group_by_key");return p(s.Stack,{children:[i(s.Group,{grow:!0,noWrap:!0,children:i(x.Controller,{name:"regression.name",control:t,render:({field:a})=>i(s.TextInput,{label:"回归线名称",sx:{flex:1},...a})})}),i(x.Controller,{name:"regression.group_by_key",control:t,render:({field:a})=>i(j,{label:"按此字段将数据分为多个系列",clearable:!0,sx:{flex:1},...a})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"regression.transform.config.method",control:t,render:({field:a})=>i(s.Select,{label:"回归方法",data:jg,sx:{flex:1},...a})}),n==="polynomial"&&i(x.Controller,{name:"regression.transform.config.order",control:t,render:({field:a})=>i(s.NumberInput,{label:"次",sx:{flex:1},...a})})]}),!r&&p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"颜色"}),i(x.Controller,{name:"regression.plot.color",control:t,render:({field:a})=>i(Pe,{...a})})]})]})}const Qg=({disabled:t,value:e,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[t&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(ze,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},Gs=y.forwardRef(({value:t,onChange:e,triggerButtonText:n="Customize Label"},r)=>{const[a,{setTrue:o,setFalse:l}]=J.useBoolean(),[c,u]=y.useState(t);y.useEffect(()=>{u(t)},[t]);const d=C=>{u({...c,enabled:C})},f=()=>{l();const{enabled:C,func_content:w}=c,_={enabled:C,func_content:w};u(_),e(_)},h=()=>{l(),u(t)},g=C=>{u(w=>({...w,func_content:C}))},m=()=>{g(zn.func_content)};return p(N,{children:[i(s.Button,{variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},children:n}),i(s.Modal,{size:800,title:"Customize label content",opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:c.enabled,onChange:C=>d(C.currentTarget.checked)}),i(Qg,{value:c.func_content,onChange:g,disabled:!c.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:m,color:"red",leftIcon:i(I.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:h,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:f,children:"OK"})]})]})]})})]})});function Kg({control:t,watch:e}){return e(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.name",control:t,render:({field:n})=>i(s.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),i(x.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>i(j,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),i(s.Stack,{children:i(x.Controller,{name:"x_axis.axisLabel.format",control:t,render:({field:n})=>i(Je,{...n})})}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>i(s.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(x.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>i(Gs,{triggerButtonText:"自定义标签文案内容",...n})})]}),i(x.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:n})=>i(gt,{...n})})]})}function Ug({control:t,watch:e}){return e(["y_axis","regression.y_axis_data_key"]),i(s.Stack,{children:p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"y_axis.name",control:t,render:({field:n})=>i(s.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),i(x.Controller,{name:"regression.y_axis_data_key",control:t,render:({field:n})=>i(j,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function Xg({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=y.useMemo(()=>v.defaults({},e,qr),[e]),{control:a,handleSubmit:o,watch:l,getValues:c,reset:u}=x.useForm({defaultValues:r});y.useEffect(()=>{u(r)},[r]),l(["x_axis","y_axis","regression"]);const d=c(),f=y.useMemo(()=>!v.isEqual(d,e),[d,e]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(I.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X轴",children:"X轴"}),i(s.Tabs.Tab,{value:"Y轴",children:"Y轴"}),i(s.Tabs.Tab,{value:"回归",children:"回归"})]}),i(s.Tabs.Panel,{value:"X轴",children:i(Kg,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"Y轴",children:i(Ug,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"回归",children:i(Yg,{control:a,watch:l})})]})]})})}function Jg(t){const e={x_axis:{axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:zn}},regression:{group_by_key:""}};return v.defaultsDeep(e,t)}function Zg(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,regression:o,...l}=t;return{...l,x_axis:{...a,data_key:r(a.data_key)},regression:{...o,group_by_key:r(o.group_by_key),y_axis_data_key:r(o.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}class Hg extends ve{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Jg(n.config)})),this.version(3,(n,r)=>{const{config:a}=n;return{...n,version:3,config:Zg(a,r)}})}}const em={displayName:"Regression Chart",displayGroup:"Merico suite",migrator:new Hg,name:"regressionChart",viewRender:Rg,configRender:Xg,createConfig(){return{version:3,config:v.cloneDeep(qr)}}},$n={content:""},Fr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}};function Ws(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(r),o=e.child(r);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=Ws(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function Rs(t,e,n,r){for(let a=t.childCount,o=e.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:r};let l=t.child(--a),c=e.child(--o),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let d=0,f=Math.min(l.text.length,c.text.length);for(;d<f&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(l.content.size||c.content.size){let d=Rs(l.content,c.content,n-1,r-1);if(d)return d}n-=u,r-=u}}class se{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,a=0,o){for(let l=0,c=0;c<n;l++){let u=this.content[l],d=c+u.nodeSize;if(d>e&&r(u,a+c,o||null,l)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,a+f)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,a){let o="",l=!0;return this.nodesBetween(e,n,(c,u)=>{c.isText?(o+=c.text.slice(Math.max(e,u)-u,n-u),l=!r):c.isLeaf?(a?o+=typeof a=="function"?a(c):a:c.type.spec.leafText&&(o+=c.type.spec.leafText(c)),l=!r):!l&&c.isBlock&&(o+=r,l=!0)},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)a.push(e.content[o]);return new se(a,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],a=0;if(n>e)for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),a+=c.nodeSize),l=u}return new se(r,a)}cutByIndex(e,n){return e==n?se.empty:e==0&&n==this.content.length?this:new se(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return a[e]=n,new se(a,o)}addToStart(e){return new se([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new se(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let a=this.content[n];e(a,r,n),r+=a.nodeSize}}findDiffStart(e,n=0){return Ws(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Rs(this,e,n,r)}findIndex(e,n=-1){if(e==0)return Ln(0,e);if(e==this.size)return Ln(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,a=0;;r++){let o=this.child(r),l=a+o.nodeSize;if(l>=e)return l==e||n>0?Ln(r+1,l):Ln(r,a);a=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,n){if(!n)return se.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new se(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return se.empty;let n,r=0;for(let a=0;a<e.length;a++){let o=e[a];r+=o.nodeSize,a&&o.isText&&e[a-1].sameMarkup(o)?(n||(n=e.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new se(n||e,r)}static from(e){if(!e)return se.empty;if(e instanceof se)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new se([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}se.empty=new se([],0);const Gr={index:0,offset:0};function Ln(t,e){return Gr.index=t,Gr.offset=e,Gr}function Wr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Wr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class We{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let a=0;a<e.length;a++){let o=e[a];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,a));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,a)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return We.none;if(e instanceof We)return[e];let n=e.slice();return n.sort((r,a)=>r.type.rank-a.type.rank),n}}We.none=[];class tm extends Error{}class ue{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ys(this.content,e+this.openStart,n);return r&&new ue(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ue(js(this.content,e+this.openStart,n+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,n){if(!n)return ue.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ue(se.fromJSON(e,n.content),r,a)}static maxOpen(e,n=!0){let r=0,a=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new ue(e,r,a)}}ue.empty=new ue(se.empty,0,0);function js(t,e,n){let{index:r,offset:a}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(a==e||o.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(js(o.content,e-a-1,n-a-1)))}function Ys(t,e,n,r){let{index:a,offset:o}=t.findIndex(e),l=t.maybeChild(a);if(o==e||l.isText)return r&&!r.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Ys(l.content,e-o-1,n);return c&&t.replaceChild(a,l.copy(c))}class On{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new Xs(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Xs(this,n,!0);return r.addAll(e,n.from,n.to),ue.maxOpen(r.finish())}matchTag(e,n,r){for(let a=r?this.tags.indexOf(r)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(im(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(e);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(e,n,r,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],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)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,a)}for(let a in e.marks){let o=e.marks[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Js(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in e.nodes){let o=e.nodes[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Js(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new On(e,On.schemaRules(e)))}}const Qs={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},nm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ks={ol:!0,ul:!0},Pn=1,Bn=2,Zt=4;function Us(t,e,n){return e!=null?(e?Pn:0)|(e==="full"?Bn:0):t&&t.whitespace=="pre"?Pn|Bn:n&~Zt}class Vn{constructor(e,n,r,a,o,l,c){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=a,this.solid=o,this.options=c,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=l||(c&Zt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(se.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(e.type))?(this.match=r,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Pn)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=se.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(se.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n<r.length;n++){let a=r[n];(this.type?this.type.allowsMarkType(a.type):sm(a.type,e))&&!a.isInSet(this.activeMarks)&&(this.activeMarks=a.addToSet(this.activeMarks),this.pendingMarks=a.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Qs.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Xs{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let a=n.topNode,o,l=Us(null,n.preserveWhitespace,0)|(r?Zt:0);a?o=new Vn(a.type,a.attrs,We.none,We.none,!0,n.topMatch||a.type.contentMatch,l):r?o=new Vn(null,null,We.none,We.none,!0,null,l):o=new Vn(e.schema.topNodeType,null,We.none,We.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(e.nodeType==3)this.addTextNode(e);else if(e.nodeType==1){let n=e.getAttribute("style");if(!n)this.addElement(e);else{let r=this.readStyles(am(n));if(!r)return;let[a,o]=r,l=this.top;for(let c=0;c<o.length;c++)this.removePendingMark(o[c],l);for(let c=0;c<a.length;c++)this.addPendingMark(a[c]);this.addElement(e);for(let c=0;c<a.length;c++)this.removePendingMark(a[c],l);for(let c=0;c<o.length;c++)this.addPendingMark(o[c])}}}addTextNode(e){let n=e.nodeValue,r=this.top;if(r.options&Bn||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Pn)r.options&Bn?n=n.replace(/\r\n?/g,`
|
|
306
|
+
`)},qr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:{...zn}}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};ce.use([G.DataZoomComponent,he.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Rg({context:t}){const{value:e}=R(t.instanceData,"config"),{width:n,height:r}=t.viewport,a=y.useMemo(()=>{var m;const u=t.data,d=e==null?void 0:e.x_axis.data_key,f=(m=e==null?void 0:e.regression)==null?void 0:m.y_axis_data_key;if(!d||!f)return[];const h=q(d),g=q(f);return u[h.queryID].map(C=>typeof C[g.columnKey]=="number"?C:{...C,[g.columnKey]:Number(C[g.columnKey])})},[t.data,e==null?void 0:e.regression.y_axis_data_key]),o=y.useMemo(()=>Lg(v.defaultsDeep({},e,qr),a),[e,a]),l=y.useRef(null),c=u=>{l.current=u};return!n||!r||!e?null:p(s.Box,{sx:{position:"relative"},children:[i(Wg,{conf:e,queryData:a}),i(Ne,{echarts:ce,onChartReady:c,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})]})}const jg=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function Yg({control:t,watch:e}){e("regression");const n=e("regression.transform.config.method"),r=e("regression.group_by_key");return p(s.Stack,{children:[i(s.Group,{grow:!0,noWrap:!0,children:i(x.Controller,{name:"regression.name",control:t,render:({field:a})=>i(s.TextInput,{label:"回归线名称",sx:{flex:1},...a})})}),i(x.Controller,{name:"regression.group_by_key",control:t,render:({field:a})=>i(j,{label:"按此字段将数据分为多个系列",clearable:!0,sx:{flex:1},...a})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"regression.transform.config.method",control:t,render:({field:a})=>i(s.Select,{label:"回归方法",data:jg,sx:{flex:1},...a})}),n==="polynomial"&&i(x.Controller,{name:"regression.transform.config.order",control:t,render:({field:a})=>i(s.NumberInput,{label:"次",sx:{flex:1},...a})})]}),!r&&p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"颜色"}),i(x.Controller,{name:"regression.plot.color",control:t,render:({field:a})=>i(Pe,{...a})})]})]})}const Qg=({disabled:t,value:e,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[t&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(ze,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},Gs=y.forwardRef(({value:t,onChange:e,triggerButtonText:n="Customize Label"},r)=>{const[a,{setTrue:o,setFalse:l}]=J.useBoolean(),[c,u]=y.useState(t);y.useEffect(()=>{u(t)},[t]);const d=C=>{u({...c,enabled:C})},f=()=>{l();const{enabled:C,func_content:w}=c,_={enabled:C,func_content:w};u(_),e(_)},h=()=>{l(),u(t)},g=C=>{u(w=>({...w,func_content:C}))},m=()=>{g(zn.func_content)};return p(N,{children:[i(s.Button,{variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},children:n}),i(s.Modal,{size:800,title:"Customize label content",opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:c.enabled,onChange:C=>d(C.currentTarget.checked)}),i(Qg,{value:c.func_content,onChange:g,disabled:!c.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:m,color:"red",leftIcon:i(I.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:h,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:f,children:"OK"})]})]})]})})]})});function Kg({control:t,watch:e}){return e(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.name",control:t,render:({field:n})=>i(s.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),i(x.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>i(j,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),i(s.Stack,{children:i(x.Controller,{name:"x_axis.axisLabel.format",control:t,render:({field:n})=>i(Je,{...n})})}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>i(s.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(x.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>i(Gs,{triggerButtonText:"自定义标签文案内容",...n})})]}),i(x.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:n})=>i(gt,{...n})})]})}function Ug({control:t,watch:e}){return e(["y_axis","regression.y_axis_data_key"]),i(s.Stack,{children:p(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"y_axis.name",control:t,render:({field:n})=>i(s.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),i(x.Controller,{name:"regression.y_axis_data_key",control:t,render:({field:n})=>i(j,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function Xg({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=y.useMemo(()=>v.defaults({},e,qr),[e]),{control:a,handleSubmit:o,watch:l,getValues:c,reset:u}=x.useForm({defaultValues:r});y.useEffect(()=>{u(r)},[r]),l(["x_axis","y_axis","regression"]);const d=c(),f=y.useMemo(()=>!v.isEqual(d,e),[d,e]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(I.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X轴",children:"X轴"}),i(s.Tabs.Tab,{value:"Y轴",children:"Y轴"}),i(s.Tabs.Tab,{value:"回归",children:"回归"})]}),i(s.Tabs.Panel,{value:"X轴",children:i(Kg,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"Y轴",children:i(Ug,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"回归",children:i(Yg,{control:a,watch:l})})]})]})})}function Jg(t){const e={x_axis:{axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:zn}},regression:{group_by_key:""}};return v.defaultsDeep(e,t)}function Zg(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,regression:o,...l}=t;return{...l,x_axis:{...a,data_key:r(a.data_key)},regression:{...o,group_by_key:r(o.group_by_key),y_axis_data_key:r(o.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}class Hg extends ve{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Jg(n.config)})),this.version(3,(n,r)=>{const{config:a}=n;return{...n,version:3,config:Zg(a,r)}})}}const em={displayName:"Regression Chart",displayGroup:"Merico suite",migrator:new Hg,name:"regressionChart",viewRender:Rg,configRender:Xg,createConfig(){return{version:3,config:v.cloneDeep(qr)}}},$n={content:""},Fr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}};function Ws(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let a=t.child(r),o=e.child(r);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=Ws(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function Rs(t,e,n,r){for(let a=t.childCount,o=e.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:r};let l=t.child(--a),c=e.child(--o),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let d=0,f=Math.min(l.text.length,c.text.length);for(;d<f&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(l.content.size||c.content.size){let d=Rs(l.content,c.content,n-1,r-1);if(d)return d}n-=u,r-=u}}class se{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,a=0,o){for(let l=0,c=0;c<n;l++){let u=this.content[l],d=c+u.nodeSize;if(d>e&&r(u,a+c,o||null,l)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,a+f)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,a){let o="",l=!0;return this.nodesBetween(e,n,(c,u)=>{c.isText?(o+=c.text.slice(Math.max(e,u)-u,n-u),l=!r):c.isLeaf?(a?o+=typeof a=="function"?a(c):a:c.type.spec.leafText&&(o+=c.type.spec.leafText(c)),l=!r):!l&&c.isBlock&&(o+=r,l=!0)},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)a.push(e.content[o]);return new se(a,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],a=0;if(n>e)for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),a+=c.nodeSize),l=u}return new se(r,a)}cutByIndex(e,n){return e==n?se.empty:e==0&&n==this.content.length?this:new se(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return a[e]=n,new se(a,o)}addToStart(e){return new se([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new se(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let a=this.content[n];e(a,r,n),r+=a.nodeSize}}findDiffStart(e,n=0){return Ws(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Rs(this,e,n,r)}findIndex(e,n=-1){if(e==0)return Ln(0,e);if(e==this.size)return Ln(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,a=0;;r++){let o=this.child(r),l=a+o.nodeSize;if(l>=e)return l==e||n>0?Ln(r+1,l):Ln(r,a);a=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,n){if(!n)return se.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new se(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return se.empty;let n,r=0;for(let a=0;a<e.length;a++){let o=e[a];r+=o.nodeSize,a&&o.isText&&e[a-1].sameMarkup(o)?(n||(n=e.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new se(n||e,r)}static from(e){if(!e)return se.empty;if(e instanceof se)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new se([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}se.empty=new se([],0);const Gr={index:0,offset:0};function Ln(t,e){return Gr.index=t,Gr.offset=e,Gr}function Wr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Wr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class We{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let a=0;a<e.length;a++){let o=e[a];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,a));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,a)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return We.none;if(e instanceof We)return[e];let n=e.slice();return n.sort((r,a)=>r.type.rank-a.type.rank),n}}We.none=[];class tm extends Error{}class ue{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ys(this.content,e+this.openStart,n);return r&&new ue(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ue(js(this.content,e+this.openStart,n+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,n){if(!n)return ue.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ue(se.fromJSON(e,n.content),r,a)}static maxOpen(e,n=!0){let r=0,a=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new ue(e,r,a)}}ue.empty=new ue(se.empty,0,0);function js(t,e,n){let{index:r,offset:a}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(a==e||o.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(js(o.content,e-a-1,n-a-1)))}function Ys(t,e,n,r){let{index:a,offset:o}=t.findIndex(e),l=t.maybeChild(a);if(o==e||l.isText)return r&&!r.canReplace(a,a,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Ys(l.content,e-o-1,n);return c&&t.replaceChild(a,l.copy(c))}class On{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new Xs(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Xs(this,n,!0);return r.addAll(e,n.from,n.to),ue.maxOpen(r.finish())}matchTag(e,n,r){for(let a=r?this.tags.indexOf(r)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(im(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(e);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(e,n,r,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],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)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,a)}for(let a in e.marks){let o=e.marks[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Js(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in e.nodes){let o=e.nodes[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Js(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new On(e,On.schemaRules(e)))}}const Qs={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},nm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ks={ol:!0,ul:!0},Pn=1,Bn=2,Zt=4;function Us(t,e,n){return e!=null?(e?Pn:0)|(e==="full"?Bn:0):t&&t.whitespace=="pre"?Pn|Bn:n&~Zt}class Vn{constructor(e,n,r,a,o,l,c){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=a,this.solid=o,this.options=c,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=l||(c&Zt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(se.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(e.type))?(this.match=r,a):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Pn)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=se.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(se.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n<r.length;n++){let a=r[n];(this.type?this.type.allowsMarkType(a.type):sm(a.type,e))&&!a.isInSet(this.activeMarks)&&(this.activeMarks=a.addToSet(this.activeMarks),this.pendingMarks=a.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Qs.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Xs{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let a=n.topNode,o,l=Us(null,n.preserveWhitespace,0)|(r?Zt:0);a?o=new Vn(a.type,a.attrs,We.none,We.none,!0,n.topMatch||a.type.contentMatch,l):r?o=new Vn(null,null,We.none,We.none,!0,null,l):o=new Vn(e.schema.topNodeType,null,We.none,We.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(e.nodeType==3)this.addTextNode(e);else if(e.nodeType==1){let n=e.getAttribute("style");if(!n)this.addElement(e);else{let r=this.readStyles(am(n));if(!r)return;let[a,o]=r,l=this.top;for(let c=0;c<o.length;c++)this.removePendingMark(o[c],l);for(let c=0;c<a.length;c++)this.addPendingMark(a[c]);this.addElement(e);for(let c=0;c<a.length;c++)this.removePendingMark(a[c],l);for(let c=0;c<o.length;c++)this.addPendingMark(o[c])}}}addTextNode(e){let n=e.nodeValue,r=this.top;if(r.options&Bn||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Pn)r.options&Bn?n=n.replace(/\r\n?/g,`
|
|
307
307
|
`):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let a=r.content[r.content.length-1],o=e.previousSibling;(!a||o&&o.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(e)}else this.findInside(e)}addElement(e,n){let r=e.nodeName.toLowerCase(),a;Ks.hasOwnProperty(r)&&this.parser.normalizeLists&&rm(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,n));if(o?o.ignore:nm.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let l,c=this.top,u=this.needsBlock;if(Qs.hasOwnProperty(r))c.content.length&&c.content[0].isInline&&this.open&&(this.open--,c=this.top),l=!0,c.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}this.addAll(e),l&&this.sync(c),this.needsBlock=u}else this.addElementByRule(e,o,o.consuming===!1?a:void 0)}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
308
308
|
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=We.none,r=We.none;for(let a=0;a<e.length;a+=2)for(let o=void 0;;){let l=this.parser.matchStyle(e[a],e[a+1],this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{l.clearMark(c)&&(r=c.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)o=l;else break}return[n,r]}addElementByRule(e,n,r){let a,o,l;n.node?(o=this.parser.schema.nodes[n.node],o.isLeaf?this.insertNode(o.create(n.attrs))||this.leafFallback(e):a=this.enter(o,n.attrs||null,n.preserveWhitespace)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u)}a&&this.sync(c)&&this.open--,l&&this.removePendingMark(l,c)}addAll(e,n,r){let a=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o);this.findAtPoint(e,a)}findPlace(e){let n,r;for(let a=this.open;a>=0;a--){let o=this.nodes[a],l=o.findWrapping(e);if(l&&(!n||n.length>l.length)&&(n=l,r=o,!l.length)||o.solid)break}if(!n)return!1;this.sync(r);for(let a=0;a<n.length;a++)this.enterInner(n[a],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(e)){this.closeExtra();let n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));let r=n.activeMarks;for(let a=0;a<e.marks.length;a++)(!n.type||n.type.allowsMarkType(e.marks[a].type))&&(r=e.marks[a].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}enter(e,n,r){let a=this.findPlace(e.create(n));return a&&this.enterInner(e,n,!0,r),a}enterInner(e,n=null,r=!1,a){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let l=Us(e,a,o.options);o.options&Zt&&o.content.length==0&&(l|=Zt),this.nodes.push(new Vn(e,n,o.activeMarks,o.pendingMarks,r,null,l)),this.open++}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)e+=r[a].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&e.nodeType==1&&e.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(r?2:4)&&(this.find[a].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(a?0:1),l=(c,u)=>{for(;c>=0;c--){let d=n[c];if(d==""){if(c==n.length-1||c==0)continue;for(;u>=o;u--)if(l(c-1,u))return!0;return!1}else{let f=u>0||u==0&&a?this.nodes[u].type:r&&u>=o?r.node(u-o).type:null;if(!f||f.name!=d&&f.groups.indexOf(d)==-1)return!1;u--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=om(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let a=this.nodes[r];if(a.pendingMarks.lastIndexOf(e)>-1)a.pendingMarks=e.removeFromSet(a.pendingMarks);else{a.activeMarks=e.removeFromSet(a.activeMarks);let l=a.popFromStashMark(e);l&&a.type&&a.type.allowsMarkType(l.type)&&(a.activeMarks=l.addToSet(a.activeMarks))}if(a==n)break}}}function rm(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ks.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function im(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function am(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function Js(t){let e={};for(let n in t)e[n]=t[n];return e}function sm(t,e){let n=e.schema.nodes;for(let r in n){let a=n[r];if(!a.allowsMarkType(t))continue;let o=[],l=c=>{o.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:f}=c.edge(u);if(d==e||o.indexOf(f)<0&&l(f))return!0}};if(l(a.contentMatch))return!0}}function om(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}const Zs=65535,Hs=Math.pow(2,16);function lm(t,e){return t+e*Hs}function eo(t){return t&Zs}function cm(t){return(t-(t&Zs))/Hs}const to=1,no=2,Nn=4,ro=8;class io{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ro)>0}get deletedBefore(){return(this.delInfo&(to|Nn))>0}get deletedAfter(){return(this.delInfo&(no|Nn))>0}get deletedAcross(){return(this.delInfo&Nn)>0}}class je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&je.empty)return je.empty}recover(e){let n=0,r=eo(e);if(!this.inverted)for(let a=0;a<r;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[r*3]+n+cm(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let a=0,o=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?a:0);if(u>e)break;let d=this.ranges[c+o],f=this.ranges[c+l],h=u+d;if(e<=h){let g=d?e==u?-1:e==h?1:n:n,m=u+a+(g<0?0:f);if(r)return m;let C=e==(n<0?u:h)?null:lm(c/3,e-u),w=e==u?no:e==h?to:Nn;return(n<0?e!=u:e!=h)&&(w|=ro),new io(m,w,C)}a+=f-d}return r?e+a:new io(e+a,0,null)}touches(e,n){let r=0,a=eo(n),o=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+o],f=u+d;if(e<=f&&c==a*3)return!0;r+=this.ranges[c+l]-d}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let a=0,o=0;a<this.ranges.length;a+=3){let l=this.ranges[a],c=l-(this.inverted?o:0),u=l+(this.inverted?0:o),d=this.ranges[a+n],f=this.ranges[a+r];e(c,c+d,u,u+f),o+=f-d}}invert(){return new je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?je.empty:new je(e<0?[0,-e,0]:[0,0,e])}}je.empty=new je([]);const Rr=Object.create(null);class Ge{getMap(){return je.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Rr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rr)throw new RangeError("Duplicate use of step JSON ID "+e);return Rr[e]=n,n.prototype.jsonID=e,n}}class _e{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new _e(e,null)}static fail(e){return new _e(null,e)}static fromReplace(e,n,r,a){try{return _e.ok(e.replace(n,r,a))}catch(o){if(o instanceof tm)return _e.fail(o.message);throw o}}}function jr(t,e,n){let r=[];for(let a=0;a<t.childCount;a++){let o=t.child(a);o.content.size&&(o=o.copy(jr(o.content,e,o))),o.isInline&&(o=e(o,n,a)),r.push(o)}return se.fromArray(r)}class _t extends Ge{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),a=r.node(r.sharedDepth(this.to)),o=new ue(jr(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),n.openStart,n.openEnd);return _e.fromReplace(e,this.from,this.to,o)}invert(){return new kt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new _t(n.pos,r.pos,this.mark)}merge(e){return e instanceof _t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _t(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new _t(n.from,n.to,e.markFromJSON(n.mark))}}Ge.jsonID("addMark",_t);class kt extends Ge{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ue(jr(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),e),n.openStart,n.openEnd);return _e.fromReplace(e,this.from,this.to,r)}invert(){return new _t(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new kt(n.pos,r.pos,this.mark)}merge(e){return e instanceof kt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new kt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new kt(n.from,n.to,e.markFromJSON(n.mark))}}Ge.jsonID("removeMark",kt);class Tt extends Ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _e.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return _e.fromReplace(e,this.pos,this.pos+1,new ue(se.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(r))return new Tt(this.pos,n.marks[a]);return new Tt(this.pos,this.mark)}}return new Ht(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Tt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Tt(n.pos,e.markFromJSON(n.mark))}}Ge.jsonID("addNodeMark",Tt);class Ht extends Ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _e.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return _e.fromReplace(e,this.pos,this.pos+1,new ue(se.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Tt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ht(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ht(n.pos,e.markFromJSON(n.mark))}}Ge.jsonID("removeNodeMark",Ht);class nt extends Ge{constructor(e,n,r,a=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=a}apply(e){return this.structure&&Yr(e,this.from,this.to)?_e.fail("Structure replace would overwrite content"):_e.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new je([this.from,this.to-this.from,this.slice.size])}invert(e){return new nt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new nt(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(e){if(!(e instanceof nt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ue.empty:new ue(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new nt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ue.empty:new ue(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new nt(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new nt(n.from,n.to,ue.fromJSON(e,n.slice),!!n.structure)}}Ge.jsonID("replace",nt);class Dt extends Ge{constructor(e,n,r,a,o,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=a,this.slice=o,this.insert=l,this.structure=c}apply(e){if(this.structure&&(Yr(e,this.from,this.gapFrom)||Yr(e,this.gapTo,this.to)))return _e.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return _e.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?_e.fromReplace(e,this.from,this.to,r):_e.fail("Content does not fit in gap")}getMap(){return new je([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Dt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),a=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||a<n.pos||o>r.pos?null:new Dt(n.pos,r.pos,a,o,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Dt(n.from,n.to,n.gapFrom,n.gapTo,ue.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ge.jsonID("replaceAround",Dt);function Yr(t,e,n){let r=t.resolve(e),a=n-e,o=r.depth;for(;a>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,a--;if(a>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function um(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function dm(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let a=t.$from.node(r),o=t.$from.index(r),l=t.$to.indexAfter(r);if(r<t.depth&&a.canReplace(o,l,n))return r;if(r==0||a.type.spec.isolating||!um(a,o,l))break}return null}function qn(t,e,n=1,r){let a=t.resolve(e),o=a.depth-n,l=r&&r[r.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let d=a.depth-1,f=n-2;d>o;d--,f--){let h=a.node(d),g=a.index(d);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(g,h.childCount),C=r&&r[f+1];C&&(m=m.replaceChild(0,C.type.create(C.attrs)));let w=r&&r[f]||h;if(!h.canReplace(g+1,h.childCount)||!w.type.validContent(m))return!1}let c=a.indexAfter(o),u=r&&r[0];return a.node(o).canReplaceWith(c,c,u?u.type:a.node(o+1).type)}function ao(t,e){let n=t.resolve(e),r=n.index();return pm(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function pm(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}class en extends Ge{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return _e.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return _e.fromReplace(e,this.pos,this.pos+1,new ue(se.from(a),0,n.isLeaf?0:1))}getMap(){return je.empty}invert(e){return new en(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new en(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new en(n.pos,n.attr,n.value)}}Ge.jsonID("attr",en);let tn=class extends Error{};tn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";const Qr=Object.create(null);class me{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new hm(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ue.empty){let r=n.content.lastChild,a=null;for(let c=0;c<n.openEnd;c++)a=r,r=r.lastChild;let o=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],f=e.mapping.slice(o);e.replaceRange(f.map(u.pos),f.map(d.pos),c?ue.empty:n),c==0&&lo(e,o,(r?r.isInline:a&&a.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:l,$to:c}=a[o],u=e.mapping.slice(r),d=u.map(l.pos),f=u.map(c.pos);o?e.deleteRange(d,f):(e.replaceRangeWith(d,f,n),lo(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let a=e.parent.inlineContent?new ke(e):Vt(e.node(0),e.parent,e.pos,e.index(),n,r);if(a)return a;for(let o=e.depth-1;o>=0;o--){let l=n<0?Vt(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Vt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ut(e.node(0))}static atStart(e){return Vt(e,e,0,0,1)||new ut(e)}static atEnd(e){return Vt(e,e,e.content.size,e.childCount,-1)||new ut(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Qr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qr[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ke.between(this.$anchor,this.$head).getBookmark()}}me.prototype.visible=!0;class hm{constructor(e,n){this.$from=e,this.$to=n}}let so=!1;function oo(t){!so&&!t.parent.inlineContent&&(so=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ke extends me{constructor(e,n=e){oo(e),oo(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return me.near(r);let a=e.resolve(n.map(this.anchor));return new ke(a.parent.inlineContent?a:r,r)}replace(e,n=ue.empty){if(super.replace(e,n),n==ue.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ke&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ke(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let a=e.resolve(n);return new this(a,r==n?a:e.resolve(r))}static between(e,n,r){let a=e.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let o=me.findFrom(n,r,!0)||me.findFrom(n,-r,!0);if(o)n=o.$head;else return me.near(n,r)}return e.parent.inlineContent||(a==0?e=n:(e=(me.findFrom(e,-r,!0)||me.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=a<0&&(e=n))),new ke(e,n)}}me.jsonID("text",ke);class Fn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Fn(e.map(this.anchor),e.map(this.head))}resolve(e){return ke.between(e.resolve(this.anchor),e.resolve(this.head))}}class Re extends me{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:a}=n.mapResult(this.anchor),o=e.resolve(a);return r?me.near(o):new Re(o)}content(){return new ue(se.from(this.node),0,0)}eq(e){return e instanceof Re&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Kr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Re(e.resolve(n.anchor))}static create(e,n){return new Re(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Re.prototype.visible=!1,me.jsonID("node",Re);class Kr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Fn(r,r):new Kr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Re.isSelectable(r)?new Re(n):me.near(n)}}class ut extends me{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ue.empty){if(n==ue.empty){e.delete(0,e.doc.content.size);let r=me.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ut(e)}map(e){return new ut(e)}eq(e){return e instanceof ut}getBookmark(){return fm}}me.jsonID("all",ut);const fm={map(){return this},resolve(t){return new ut(t)}};function Vt(t,e,n,r,a,o=!1){if(e.inlineContent)return ke.create(t,n);for(let l=r-(a>0?0:1);a>0?l<e.childCount:l>=0;l+=a){let c=e.child(l);if(c.isAtom){if(!o&&Re.isSelectable(c))return Re.create(t,n-(a<0?c.nodeSize:0))}else{let u=Vt(t,c,n+a,a<0?c.childCount:0,a,o);if(u)return u}n+=c.nodeSize*a}return null}function lo(t,e,n){let r=t.steps.length-1;if(r<e)return;let a=t.steps[r];if(!(a instanceof nt||a instanceof Dt))return;let o=t.mapping.maps[r],l;o.forEach((c,u,d,f)=>{l==null&&(l=f)}),t.setSelection(me.near(t.doc.resolve(l),n))}function co(t,e){return!e||!t?t:t.bind(e)}class Gn{constructor(e,n,r){this.name=e,this.init=co(n.init,r),this.apply=co(n.apply,r)}}new Gn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gn("selection",{init(t,e){return t.selection||me.atStart(e.doc)},apply(t){return t.selection}}),new Gn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function uo(t,e,n){for(let r in t){let a=t[r];a instanceof Function?a=a.bind(e):r=="handleDOMEvents"&&(a=uo(a,e,{})),n[r]=a}return n}class nn{constructor(e){this.spec=e,this.props={},e.props&&uo(e.props,this,this.props),this.key=e.key?e.key.key:po("plugin")}getState(e){return e[this.key]}}const Ur=Object.create(null);function po(t){return t in Ur?t+"$"+ ++Ur[t]:(Ur[t]=0,t+"$")}class rn{constructor(e="key"){this.key=po(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}function ho(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:a}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return a},get tr(){return r=n.selection,a=n.doc,o=n.storedMarks,n}}}class gm{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:n,state:r}=this,{view:a}=n,{tr:o}=r,l=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...f)=>{const h=u(...f)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:a,state:o}=this,{view:l}=a,c=[],u=!!e,d=e||o.tr,f=()=>(!u&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(g=>g===!0)),h={...Object.fromEntries(Object.entries(r).map(([g,m])=>[g,(...w)=>{const _=this.buildProps(d,n),T=m(...w)(_);return c.push(T),h}])),run:f};return h}createCan(e){const{rawCommands:n,state:r}=this,a=!1,o=e||r.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(n).map(([u,d])=>[u,(...f)=>d(...f)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(e,n=!0){const{rawCommands:r,editor:a,state:o}=this,{view:l}=a;o.storedMarks&&e.setStoredMarks(o.storedMarks);const c={tr:e,editor:a,view:l,state:ho({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...f)=>d(...f)(c)]))}};return c}}function bt(t,e,n){return t.config[e]===void 0&&t.parent?bt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?bt(t.parent,e,n):null}):t.config[e]}function mm(t){const e=t.filter(a=>a.type==="extension"),n=t.filter(a=>a.type==="node"),r=t.filter(a=>a.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Le(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function ym(t){return typeof t=="function"}function Nt(t,e=void 0,...n){return ym(t)?e?t.bind(e)(...n):t(...n):t}function bm(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function vm(t){return Object.prototype.toString.call(t).slice(8,-1)}function Xr(t){return vm(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function fo(t,e){const n={...t};return Xr(t)&&Xr(e)&&Object.keys(e).forEach(r=>{Xr(e[r])?r in t?n[r]=fo(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}class rt{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&&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=Nt(bt(this,"addOptions",{name:this.name}))),this.storage=Nt(bt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new rt(e)}configure(e={}){const n=this.extend();return n.options=fo(this.options,e),n.storage=Nt(bt(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new rt(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=Nt(bt(n,"addOptions",{name:n.name})),n.storage=Nt(bt(n,"addStorage",{name:n.name,options:n.options})),n}}function xm(t,e,n){const{from:r,to:a}=e,{blockSeparator:o=`
|
|
309
309
|
|