unione-form-vue 0.0.15 → 0.0.16

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/index.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function(ee,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("unione-base-vue"),require("vue"),require("ant-design-vue"),require("lodash-es"),require("vue-codemirror"),require("@codemirror/lang-javascript"),require("@ant-design/icons-vue"),require("uuid")):typeof define=="function"&&define.amd?define(["exports","unione-base-vue","vue","ant-design-vue","lodash-es","vue-codemirror","@codemirror/lang-javascript","@ant-design/icons-vue","uuid"],K):(ee=typeof globalThis<"u"?globalThis:ee||self,K(ee.index={},ee.UnioneBaseVue,ee.Vue,ee.antDesignVue,ee.lodashEs,ee.vueCodemirror,ee.langJavascript,ee.iconsVue,ee.uuid))})(this,function(ee,K,i,J,na,Lt,la,He,sa){"use strict";const oa={isDebug:!0,axios:{form:"/portal"},listPageUrl:"/unione/page/list",addPageUrl:"/unione/page/add",editPageUrl:"/unione/page/edit",viewPageUrl:"/unione/page/view",formRules:[]},Ji=i.ref(oa);function Ie(o){return o&&(Ji.value=K.utils.obj.ext(Ji.value,o)),Ji.value}const aa={...{...{submit:"提交","submit.ok":"已提交","submit.error":"提交失败","confirm.ok":"确定","confirm.cancel":"取消","global.setting.title":"设置"},...{"pages.home":"首页"},...{"pages.layouts.userLayout.title":"user layout"}}},ra={...{submit:"Submit","submit.ok":"Submitted","submit.error":"Submit Failed","confirm.ok":"Yes","confirm.cancel":"No","global.setting.title":"Settings"},...{"pages.home":"Home"},...{"pages.layouts.userLayout.title":"user layout"}},da=i.ref([aa,ra]);function ca(o,e){return K.locales.loadLanguage(o,()=>new Promise((t,n)=>{const l=da.value.filter(s=>s.localeName==o);if(e)if(typeof e=="function")e().then(s=>{if(l.length==0){const a={...s,localeName:o};t(a)}else{const a={...l[0],...s};t(a)}});else if(l.length==0){const s={...e,localeName:o};t(s)}else{const s={...l[0],...e};t(s)}else l.length>0?t(l[0]):n("local language not defined ,lang:"+o)}))}const Zi={...K.locales};Zi.loadLanguage=ca;class ha{$psn;$pid;$store;$forms;$model;$params;$refObj;$refData;constructor(e,t){this.$psn=i.ref(e),this.$pid=i.ref(""),this.$store=i.ref({}),this.$forms=i.ref({}),this.$params=i.ref({}),this.$refObj=i.ref({}),this.$refData=i.ref({}),this.$model=t}params(e){if(e){this.$params.value=e,e.id&&(this.$pid.value=e.id,this.$psn.value&&this.use(this.$psn.value,"form").detail(this.$pid.value));for(const t in this.$store.value)this.$store.value[t].$params=e}return this.$params.value}psn(e){return e&&(this.$psn.value=e),this.$psn.value}regRef(e,t){}setRefData(e,t,n){}use(e,t,n){let l=this.$store.value[e];return l||(l=new en(e,t,this.$model),this.$store.value[e]=l,l.$params=this.$params.value),n&&(l.$form=n,this.$forms.value[e]=n),l}useForm(e,t,n){const l=this.use(e,"form",t);return this.$psn.value==e&&this.$pid.value&&l.detail(this.$pid.value).then(s=>{n&&n(s)}),l}data(e){return this.$store.value[e]}form(e){return e?this.$forms.value[e]:this.$forms.value}primary(){return this.data(this.$psn.value)}dsnList(){return Object.keys(this.$store.value)}}class en{$dsn;$type;$data;$dialog;$model;$form;$params;$store;constructor(e,t,n){typeof e=="string"?(this.$dsn=e,this.$store={controller:"/api/data/storage/v1"}):(this.$store=e,this.$dsn=""),this.$type=t,this.$data=i.ref(t=="form"?{}:{body:[],total:0}),this.$dialog=K.useDialog(),this.$model=n||i.ref("run")}$isStorage(){return this.$store.controller.indexOf("/api/data/storage")>=0}store(e){return e&&(this.$store=e),this.$store}data(){return this.$type=="form"?this.$data.value||{}:this.$data.value||[]}setValue(e){this.$data.value=e,this.$form?.setValue(e)}$processParams(e,t){if(t)t.forEach(n=>{e[n.name]==null&&e[n.name]==null&&(this.$params[n.name]!=null&&this.$params[n.name]!=null?e[n.alias||n.name]=this.$params[n.name]:n.value!=null&&n.value!=null&&(e[n.alias||n.name]=n.value))});else if(this.$params)for(const n in this.$params)e[n]==null&&e[n]==null&&this.$params[n]!=null&&this.$params[n]!=null&&(e[n]=this.$params[n]);return e}request(e){return new Promise((t,n)=>{const l=J.message.loading("数据请求中..."),s=this.$store.controller+e.url;K.axios.form({method:"post",...e,url:s}).then(a=>{a.success?t(a):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),n({info:"数据请求失败,model sn:"+this.$dsn+",url:"+s,options:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据请求失败,model sn:"+this.$dsn+",url:"+s,options:e,err:a})}).finally(()=>{l()})})}find(e){const t=this.$store.controller+(this.$store.findUrl||"/find");return!e&&this.$store.findParams&&(e={dsn:this.$dsn}),this.$isStorage()&&(e.dsn=this.$dsn+(this.$model!="run"?"@dev":"")),e&&(e.body=this.$processParams(e.body,this.$store.findParams)),new Promise((n,l)=>{const s=J.message.loading("数据加载中...");K.axios.form({url:t,method:"post",data:e}).then(a=>{a.success?(this.$data.value=a,n(a)):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),l({info:"数据加载失败,model sn:"+this.$dsn,url:t,params:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),l({info:"数据加载失败,model sn:"+this.$dsn,url:t,params:e,err:a})}).finally(()=>{s()})})}save(e){const t=this.$store.controller+(this.$store.saveUrl||"/save");return this.$isStorage()?(e.dsn=this.$dsn+(this.$model!="run"?"@dev":""),e.params=this.$processParams(e.params,this.$store.saveParams)):e.data=this.$processParams(e.data,this.$store.saveParams),new Promise((n,l)=>{const s=J.message.loading("数据提交中...");K.axios.form({url:t,method:"post",data:this.$isStorage()?e:e.data}).then(a=>{a.success?(this.$type=="form"&&(this.$data.value=a.body||{}),a.silence||J.message.success(a.message),n(a)):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),l({info:"数据保存失败,model sn:"+this.$dsn,url:t,data:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),l({info:"数据保存失败,model sn:"+this.$dsn,url:t,data:e,err:a})}).finally(()=>{s()})})}loadByIds(e){return new Promise((t,n)=>{const l=J.message.loading("数据加载中..."),s=this.$store.controller+"/loadByIds";K.axios.form({url:s,method:"post",data:this.$isStorage()?{ids:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(a=>{a.success?t(a):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),n({info:"数据加载失败,model sn:"+this.$dsn,ids:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据加载失败,model sn:"+this.$dsn,ids:e,err:a})}).finally(()=>{l()})})}detail(e){return new Promise((t,n)=>{const l=J.message.loading("数据加载中..."),s=this.$store.controller+"/detail";K.axios.form({url:s,method:"post",data:this.$isStorage()?{id:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(a=>{a.success?(this.$type=="form"&&(this.$data.value=a.body),t(a)):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),n({info:"加载数据详情失败,model sn:"+this.$dsn,url:s,id:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"加载数据详情失败,model sn:"+this.$dsn,url:s,id:e,err:a})}).finally(()=>{l()})})}deleteByIds(e){return new Promise((t,n)=>{this.$dialog.confirm({content:"确定要删除选中记录么?共"+e.length+"条。",onOk:()=>{const l=J.message.loading("数据处理中..."),s=this.$store.controller+"/delete";K.axios.form({url:s,method:"post",data:this.$isStorage()?{ids:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(a=>{a.success?t(a):(a.silence||this.$dialog.error({content:a.message||"未知错误,请联系管理员"}),n({info:"数据删除失败,model sn:"+this.$dsn,url:s,ids:e,result:a}))}).catch(a=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据删除失败,model sn:"+this.$dsn,url:s,ids:e,err:a})}).finally(()=>{l()})}})})}}class fa{$event;$onces;$delayEmit;constructor(){this.$event=i.ref({}),this.$onces=i.ref({}),this.$delayEmit=i.ref({})}$on(e,t){if(this.$event.value[e]=t,this.$delayEmit.value[e]){const n=this.$delayEmit.value[e];t(n)}}$emit(e,t){if(this.$onces.value[e]){const n=this.$onces.value[e];delete this.$onces.value[e],n(t)}this.$event.value[e]?this.$event.value[e](t):(this.$delayEmit.value[e]=t,setTimeout(()=>{delete this.$delayEmit.value[e]},1e3*10))}$once(e,t){this.$onces.value[e]=t}$off(e){delete this.$event.value[e]}}class ct{define;ebus;model;type;$widgetList;$widgetMap;$dataManager;$axiosProccess;$dialog;constructor(e={sn:"new_",title:"新建页面",types:"setting",vers:1,configs:{widgets:[],dsnList:[]}}){const t=e.configs||{};this.model=i.ref("run"),this.type=i.ref(e.types||"setting"),this.define=i.ref(e),this.ebus=new fa,this.$widgetList=i.ref([]),this.$widgetMap=i.ref({}),this.$dataManager=new ha(t.dsnList?t.dsnList[0]:"",this.model),this.$axiosProccess=i.ref({}),this.$dialog=K.useDialog(),this.loadConfig(t)}sn(){return this.define.value.sn}load(e,t){if(!e)return;if(this.define.value.sn=e,e=="new_"){console.log("新建/本地页面sn:"+e+",define:",t),t&&t.configs&&(this.define.value=t,this.type.value=this.define.value.types||"setting",this.loadConfig(t.configs));return}const n=sessionStorage.getItem("PAGE_DEFINE:"+e);if(n&&this.model.value=="run"){this.define.value=JSON.parse(n),this.type.value=this.define.value.types||"setting",this.loadConfig(this.define.value.configs),console.log("从会话缓存中加载页面sn:"+e+",define:",this.define.value);return}K.axios.form({url:"/api/page/define/load/"+e,method:"post"}).then(l=>{l.success?(this.define.value=l.body,this.type.value=this.define.value.types||"setting",l.body.configs?this.define.value.configs=l.body.configs:this.define.value.configs={widgets:[],dsnList:[]},this.loadConfig(this.define.value.configs),sessionStorage.setItem("PAGE_DEFINE:"+e,JSON.stringify(this.define.value)),console.log("从远程服务加载页面sn:"+e+",define:",this.define.value)):t&&t.configs&&(this.define.value=t,this.loadConfig(t.configs))})}save(){return new Promise((e,t)=>{if(this.$axiosProccess.value.save){console.warn("unione form editor save process runing,sn:"+this.define.value.sn),t();return}this.$axiosProccess.value.save=!0;const n={...this.define.value.configs||{},widgets:this.$widgetList.value,dsnList:this.$dataManager.dsnList()},l={...this.define.value};l.configs=JSON.stringify(n),K.axios.form({url:"/api/page/define/save",method:"post",data:l}).then(s=>{this.$axiosProccess.value.save=!1,s.success?(J.message.success(s.message),this.define.value=s.body,sessionStorage.setItem("PAGE_DEFINE:"+this.define.value.sn,JSON.stringify(this.define.value)),this.load(this.define.value.sn,this.define.value),e(s.body)):(this.$dialog.error({content:s.message}),t())}).catch(s=>{console.error("页面配置保存失败",s),this.$dialog.error({content:"页面配置保存失败"})}).finally(()=>{this.$axiosProccess.value.save=!1})})}loadConfig(e){e.dsnList?.length&&this.$dataManager.psn(e.dsnList[0]),this.$widgetList.value=e.widgets||[],this.$widgetMap.value={},this.$processWidget(this.$widgetList.value)}setModel(e){this.model.value=e}widget(e,t){if(t){const n={...t,wid:e};this.$widgetMap.value[e]||(this.$widgetList.value.push(n),n.configs?.widgets&&this.$processWidget(n.configs.widgets)),this.$widgetMap.value[e]=n}else return this.$widgetMap.value[e]}widgets(e){if(e)this.$widgetList.value=e,this.$widgetMap.value={},this.$processWidget(e);else return this.$widgetList.value}$processWidget(e){e.forEach(t=>{t.wid||(t.wid="w:"+na.uniqueId()),this.$widgetMap.value[t.wid]=t,t.configs?.widgets&&this.$processWidget(t.configs.widgets)})}dataManager(){return this.$dataManager}}const ua={class:"widget-setting-dialog"},pa=i.defineComponent({__name:"widget",props:{model:{type:String,required:!1},settingTitle:{type:String,default:"组件设置"},custome:{type:Boolean,default:!1}},emits:["setting","saving"],setup(o,{emit:e}){const t=e,n=i.ref(),l=i.ref(!1);function s(){n.value&&(l.value=!0),t("setting")}function a(){t("saving"),l.value=!1}return(r,d)=>{const h=i.resolveComponent("SettingOutlined"),f=i.resolveComponent("a-tooltip"),c=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-widget",o.model])},[i.createVNode(f,{title:o.settingTitle},{default:i.withCtx(()=>[o.model=="edit"&&(r.$slots["widget-setting"]||o.custome)?(i.openBlock(),i.createBlock(h,{key:0,class:"widget-setting",onClick:s})):i.createCommentVNode("",!0)]),_:1},8,["title"]),i.renderSlot(r.$slots,"default",{},void 0,!0),o.model=="edit"&&r.$slots["widget-setting"]?(i.openBlock(),i.createBlock(c,{key:0,title:o.settingTitle,ref_key:"settingModal",ref:n,open:l.value,"onUpdate:open":d[0]||(d[0]=u=>l.value=u),centered:"",width:"80%",onOk:a},{default:i.withCtx(()=>[i.createElementVNode("div",ua,[i.renderSlot(r.$slots,"widget-setting",{},void 0,!0)])]),_:3},8,["title","open"])):i.createCommentVNode("",!0)],2)}}}),ne=(o,e)=>{const t=o.__vccOpts||o;for(const[n,l]of e)t[n]=l;return t},ht=ne(pa,[["__scopeId","data-v-3a88c0c0"]]),ma={key:0},ga=["onClick"],ci=ne(i.defineComponent({__name:"btnSetting",props:{preset:{type:Array,default(){return[]}}},setup(o,{expose:e}){const t=o,n=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:g})=>g+1},{title:"参数名称",dataIndex:"name",key:"name",width:"60px",align:"center"},{title:"参数标题",dataIndex:"title",key:"title",width:"80px",align:"center"},{title:"参数value",dataIndex:"value",key:"value",width:"100px",align:"center"}]),l=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:g=>{l.value.selectedRowKeys=g}}),s={mounted:g=>g.focus()},a=i.ref({});function r(){const g=Object.keys(a.value);if(g.length)for(let p in g){const N=y.value.form.action.params[p];N&&a.value[p]&&Object.keys(a.value[p]).forEach(V=>{N[V]=a.value[p][V]})}a.value={}}function d(g,p,N){r();const V={};V[N]=p[N]||"",N=="showIndex"&&(V[N]=p.show?.query?.index),a.value[g]=V}function h(g,p,N){if(!p||!N){a.value={};return}const V=a.value[g][N];p[N]=V,a.value={}}function f(){y.value.form.action.params.push({title:"新建",name:"",value:""})}function c(){}const u=i.ref(""),m=i.ref({title:[{required:!0,message:"按钮标题不能为空"}],name:[{required:!0,message:"按钮名称不能为空"},{validator:(g,p)=>u.value!=p&&t.preset.includes(p)?Promise.reject("预设按钮名称,请使用其他名称,["+t.preset.join(",")+"]"):Promise.resolve(),trigger:"change"}]}),b=i.ref([la.javascript()]),y=i.ref({title:"按钮设置",visible:!1,form:{},helps:{}}),k=i.ref();function v(g,p,N={}){g=JSON.parse(JSON.stringify(g)),g.event||(g.event={}),g.props||(g.props={}),g.action||(g.action={}),Object.keys(g.action).includes("maskClosable")||(g.action.maskClosable=!0),g.action.params||(g.action.params=[]),u.value=g.name,y.value.form=g,y.value.helps=N,y.value.visible=!0,k.value=p}const w=i.ref(null);function O(){w.value&&w.value.validate().then(()=>{y.value.visible=!1,k.value(y.value.form)})}return e({open:v,close}),(g,p)=>{const N=i.resolveComponent("a-input"),V=i.resolveComponent("a-form-item"),C=i.resolveComponent("a-select"),x=i.resolveComponent("a-input-number"),S=i.resolveComponent("a-checkbox"),M=i.resolveComponent("a-tab-pane"),T=i.resolveComponent("a-switch"),E=i.resolveComponent("a-button"),I=i.resolveComponent("a-divider"),L=i.resolveComponent("ToolOutlined"),A=i.resolveComponent("a-tooltip"),U=i.resolveComponent("a-table"),P=i.resolveComponent("a-tabs"),G=i.resolveComponent("a-form"),j=i.resolveComponent("a-modal");return i.openBlock(),i.createBlock(j,{visible:y.value.visible,"onUpdate:visible":p[23]||(p[23]=B=>y.value.visible=B),title:y.value.title,centered:"",width:"50%",onOk:O},{default:i.withCtx(()=>[i.createVNode(G,{name:"basic",ref_key:"form",ref:w,rules:m.value,model:y.value.form,"label-col":{span:5},"wrapper-col":{span:19},autocomplete:"off",class:"form-mix btn-setting-form"},{default:i.withCtx(()=>[i.createVNode(P,null,{default:i.withCtx(()=>[i.createVNode(M,{key:"base",tab:"基本设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"操作标题",required:"",name:"title"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.title,"onUpdate:value":p[0]||(p[0]=B=>y.value.form.title=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"操作名称",name:"name",required:""},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.name,"onUpdate:value":p[1]||(p[1]=B=>y.value.form.name=B),disabled:t.preset.includes(y.value.form.name)},null,8,["value","disabled"])]),_:1}),i.createVNode(V,{label:"操作图标"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.icon,"onUpdate:value":p[2]||(p[2]=B=>y.value.form.icon=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.type,"onUpdate:value":p[3]||(p[3]=B=>y.value.form.type=B),allowClear:"",options:[{value:"primary",label:"主要按钮"},{value:"ghost",label:"幽灵按钮"},{value:"dashed",label:"虚线按钮"},{value:"link",label:"连接按钮"},{value:"text",label:"文本按钮"},{value:"default",label:"默认按钮"}]},null,8,["value"])]),_:1}),i.createVNode(V,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.index,"onUpdate:value":p[4]||(p[4]=B=>y.value.form.index=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮大小"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.size,"onUpdate:value":p[5]||(p[5]=B=>y.value.form.size=B),options:[{value:"small",label:"小"},{value:"middle",label:"中"},{value:"large",label:"大"}]},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮特性"},{default:i.withCtx(()=>[i.createVNode(S,{checked:y.value.form.props.block,"onUpdate:checked":p[6]||(p[6]=B=>y.value.form.props.block=B)},{default:i.withCtx(()=>p[24]||(p[24]=[i.createTextVNode("自适应 ")])),_:1},8,["checked"]),i.createVNode(S,{checked:y.value.form.props.danger,"onUpdate:checked":p[7]||(p[7]=B=>y.value.form.props.danger=B)},{default:i.withCtx(()=>p[25]||(p[25]=[i.createTextVNode("危险 ")])),_:1},8,["checked"]),i.createVNode(S,{checked:y.value.form.props.ghost,"onUpdate:checked":p[8]||(p[8]=B=>y.value.form.props.ghost=B)},{default:i.withCtx(()=>p[26]||(p[26]=[i.createTextVNode("幽灵 ")])),_:1},8,["checked"])]),_:1})]),_:1}),i.createVNode(M,{key:"action",tab:"响应设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"响应方式",required:""},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.type,"onUpdate:value":p[9]||(p[9]=B=>y.value.form.action.type=B),options:[{value:"link",label:"连接"},{value:"route",label:"路由"},{value:"drawer",label:"抽屉"},{value:"dialog",label:"对话框"}]},null,8,["value"])]),_:1}),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:0,label:"页面编码",help:"根据该页面编码渲染页面内容"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.psn,"onUpdate:value":p[10]||(p[10]=B=>y.value.form.action.psn=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:1,label:"组件名称",help:"组件方式渲染,Vue全局注册的组件名称,且监听params参数,psn参数"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.component,"onUpdate:value":p[11]||(p[11]=B=>y.value.form.action.component=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),i.createVNode(V,{label:"连接地址"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.href,"onUpdate:value":p[12]||(p[12]=B=>y.value.form.action.href=B)},null,8,["value"])]),_:1}),["link","route"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:2,label:"连接方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.target,"onUpdate:value":p[13]||(p[13]=B=>y.value.form.action.target=B),options:[{value:"_blank",label:"新卡片页"},{value:"_self",label:"当前页面"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:3,label:"抽屉位置"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.position,"onUpdate:value":p[14]||(p[14]=B=>y.value.form.action.position=B),options:[{value:"left",label:"左侧"},{value:"right",label:"右侧"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:4,label:"显示标题",required:""},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.title,"onUpdate:value":p[15]||(p[15]=B=>y.value.form.action.title=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:5,label:"蒙层关闭"},{default:i.withCtx(()=>[i.createVNode(T,{checked:y.value.form.action.maskClosable,"onUpdate:checked":p[16]||(p[16]=B=>y.value.form.action.maskClosable=B),"checked-children":"开","un-checked-children":"关"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:6,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.action.width,"onUpdate:value":p[17]||(p[17]=B=>y.value.form.action.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:7,label:"显示高度"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.action.height,"onUpdate:value":p[18]||(p[18]=B=>y.value.form.action.height=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),i.createVNode(I,{orientation:"left"},{default:i.withCtx(()=>[p[29]||(p[29]=i.createTextVNode("参数列表 ")),i.createVNode(E,{size:"small",class:"param-btn",onClick:f},{default:i.withCtx(()=>p[27]||(p[27]=[i.createTextVNode("添加")])),_:1}),i.createVNode(E,{size:"small",class:"param-btn",danger:"",onClick:c},{default:i.withCtx(()=>p[28]||(p[28]=[i.createTextVNode("删除")])),_:1})]),_:1}),i.createVNode(U,{columns:n.value,"data-source":y.value.form.action.params,bordered:"",pagination:!1,"row-selection":l.value,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:B})=>[["name","title"].includes(B.key)?(i.openBlock(),i.createElementBlock("span",ma,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(B.title),1)])):i.createCommentVNode("",!0),["value"].includes(B.key)?(i.openBlock(),i.createBlock(A,{key:1,title:"支持常量和变量,变量使用{row.属性}方式获取"},{default:i.withCtx(()=>[i.createElementVNode("span",null,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(B.title),1)])]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:B,text:F,record:_,index:D})=>[["name","title","value"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!a.value[D]||!Object.keys(a.value[D]).includes(B.dataIndex))&&!F&&"empty"]),onClick:$=>d(D,_,B.dataIndex)},[a.value[D]&&Object.keys(a.value[D]).includes(B.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(N,{key:0,value:a.value[D][B.dataIndex],"onUpdate:value":$=>a.value[D][B.dataIndex]=$,onBlur:$=>h(D,_,B.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[s]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(F),1)],64))],10,ga)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])]),_:1}),i.createVNode(M,{key:"event",tab:"事件设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"点击事件",help:y.value.helps.clickScript||"点击事件处理脚本,上下文参数:ctx,当前按钮对象:btn,当前事件对象:event,返回false则不触发默认逻辑"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.clickScript,"onUpdate:modelValue":p[19]||(p[19]=B=>y.value.form.event.clickScript=B),placeholder:"请输入点击事件处理脚本",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"禁用逻辑",help:y.value.helps.disableScript||"按钮禁用逻辑控制脚本,上下文参数:ctx,当前按钮对象:btn,返回true禁用,否则可用"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.disableScript,"onUpdate:modelValue":p[20]||(p[20]=B=>y.value.form.event.disableScript=B),placeholder:"请输入按钮禁用逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"显示逻辑",help:y.value.helps.visibleScript||"按钮显示逻辑控制脚本,上下文参数:ctx,当前按钮对象:btn,返回false隐藏,否则可见"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.visibleScript,"onUpdate:modelValue":p[21]||(p[21]=B=>y.value.form.event.visibleScript=B),placeholder:"请输入按钮显示逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"动态标题",help:y.value.helps.titleScript||"按钮显示标题控制脚本,上下文参数:ctx,当前按钮对象:btn"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.titleScript,"onUpdate:modelValue":p[22]||(p[22]=B=>y.value.form.event.titleScript=B),placeholder:"请输入按钮动态标题逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"])]),_:1})]),_:1})]),_:1},8,["rules","model"])]),_:1},8,["visible","title"])}}}),[["__scopeId","data-v-75055a2b"]]),ka=["src"],ba=["src"],ya=ne(i.defineComponent({__name:"btn",props:{editor:{type:Object,required:!1},disabled:{type:Boolean,default:!1},type:{type:String},widget:{type:Object,required:!0,default(){return{}}},preset:{type:Array,default(){return[]}},ctx:{type:Object,default(){return{}}}},emits:["click"],setup(o,{emit:e}){const t=Ie(),n=o,l=K.useSession();i.watch(()=>n.widget?.event,()=>{a()}),i.onMounted(()=>{a()});const s=i.ref({});function a(){n.widget?.event&&(n.widget.event.clickScript?s.value.click=new Function("ctx","btn","event",n.widget.event.clickScript):n.widget.event.click&&(s.value.click=n.widget.event.click),n.widget.event.disableScript?s.value.disable=new Function("ctx","btn",n.widget.event.disableScript):n.widget.event.disable&&(s.value.disable=n.widget.event.disable),n.widget.event.visibleScript?s.value.visible=new Function("ctx","btn",n.widget.event.visibleScript):n.widget.event.visible&&(s.value.visible=n.widget.event.visible),n.widget.event.titleScript?s.value.title=new Function("ctx","btn",n.widget.event.titleScript):n.widget.event.title&&(s.value.title=n.widget.event.title)),typeof n.widget.click=="function"&&(s.value.click=n.widget.click),typeof n.widget.title=="function"&&(s.value.title=n.widget.title),typeof n.widget.visible=="function"&&(s.value.visible=n.widget.visible),typeof n.widget.disabled=="function"&&(s.value.disable=n.widget.disabled)}const r=i.computed(()=>s.value.title?s.value.title(u.value,n.widget):n.widget.title),d=i.computed(()=>s.value.visible?s.value.visible(u.value,n.widget)!=!1:n.widget.visible!=!1),h=i.computed(()=>n.disabled==!0?!0:s.value.disable?s.value.disable(u.value,n.widget):n.widget.disable==!0),f=i.ref(null);function c(){f.value?.open(n.widget,g=>{console.log("btn props",g),Object.keys(g).forEach(p=>{n.widget[p]=g[p]}),console.log("props btn",n.widget)})}const u=i.computed(()=>({...n.ctx,user:l.getPrincipal(),token:l.getToken()})),m=i.ref({open:!1}),b=i.computed(()=>{if(n.widget.action?.href){let g=n.widget.action.href;const p=g.matchAll("{[a-zA-Z.]*}"),N=[];let V=null;for(;V=p.next();){if(V&&V.value&&V.value[0]){let C=V.value[0].substring(1,V.value[0].length-1);N.includes(C)||N.push(C)}if(V.done)break}if(N.length>0)for(let C=0;C<N.length;C++){let x=N[C],S=K.utils.obj.getValue(u.value,x);S?S instanceof Object?g=g.replaceAll("{"+x+"}",JSON.stringify(S)):Array.isArray(S)?g=g.replaceAll("{"+x+"}",S.join(",")):g=g.replaceAll("{"+x+"}",S):g=g.replaceAll("{"+x+"}","")}return g}return""}),y=i.computed(()=>{const g={};let p=n.widget.action?.href||n.widget.action?.link;if(p){const N=p.matchAll("{[a-zA-Z0-9.]*}"),V=[];let C=null;for(;C=N.next();){if(C&&C.value&&C.value[0]){let S=C.value[0].substring(1,C.value[0].length-1);V.includes(S)||V.push(S)}if(C.done)break}if(V.length>0)for(let S=0;S<V.length;S++){let M=V[S],T=K.utils.obj.getValue(u.value,M);T?T instanceof Object?p=p.replaceAll("{"+M+"}",JSON.stringify(T)):Array.isArray(T)?p=p.replaceAll("{"+M+"}",T.join(",")):p=p.replaceAll("{"+M+"}",T):p=p.replaceAll("{"+M+"}","")}const x=p.split("?")[1];x&&x.split("&").forEach(S=>{const M=S.split("=");M[0]&&M[1]&&(g[M[0]]=M[1])})}return n.widget.action?.params&&n.widget.action.params.filter(N=>N.value+"").forEach(N=>{if(new RegExp("{[a-zA-Z0-9.]*}").test(N.value)){let C=K.utils.obj.getValue(u.value,N.value);g[N.name]=C}else g[N.name]=N.value}),g}),k=e,v=i.inject("router");function w(g){if(t.isDebug&&console.log("unione btn click",n.widget,g),!(s.value.click&&s.value.click(u.value,n.widget,g)==!1)){if(n.widget.action?.type=="drawer"||n.widget.action?.type=="dialog")m.value.open=!0;else if(n.widget.action?.type=="route"&&(n.widget.action?.href||n.widget.action?.link)){if(n.widget.action.link&&n.editor?.type.value=="code")return;v.push({path:n.widget.action.href||n.widget.action?.link,query:y.value})}k("click",{btn:n.widget,event:g})}}function O(g){k("click",g)}return(g,p)=>{const N=i.resolveComponent("a-button"),V=i.resolveComponent("unione-btn"),C=i.resolveComponent("a-dropdown"),x=i.resolveComponent("a-drawer"),S=i.resolveComponent("a-modal");return d.value?(i.openBlock(),i.createBlock(ht,{key:0,class:i.normalizeClass(["unione-btn",o.widget.props?.block&&"unione-btn-block"]),model:o.editor?.model.value,onSetting:c,custome:!0,"setting-title":"按钮设置"},{default:i.withCtx(()=>[!o.widget.widget||o.widget.widget=="button"?(i.openBlock(),i.createBlock(N,i.mergeProps({key:0,disabled:h.value,size:o.widget.size||"small",type:o.type||o.widget.type,shape:o.widget.shape,class:"unione-btn-"+o.widget.name,loading:o.widget.loading,target:o.widget.action?.target,title:o.widget.tooltip,onClick:w},o.widget.props),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value)+" ",1)]),_:2},[o.widget.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(o.widget.icon)))]),key:"0"}:void 0]),1040,["disabled","size","type","shape","class","loading","target","title"])):i.createCommentVNode("",!0),o.widget.widget=="dropdown"?(i.openBlock(),i.createBlock(C,{key:1,trigger:[o.widget.trigger||"hover"],class:i.normalizeClass([o.widget.size||"small"])},{overlay:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["dropdown-overlay",o.widget.layout])},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(o.widget.items,M=>(i.openBlock(),i.createBlock(V,{key:M.name,class:"item",widget:M,editor:o.editor,preset:o.preset,ctx:o.ctx,onClick:O},null,8,["widget","editor","preset","ctx"]))),128))],2)]),default:i.withCtx(()=>[i.createVNode(N,{size:o.widget.size||"small"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value),1)]),_:1},8,["size"])]),_:1},8,["trigger","class"])):i.createCommentVNode("",!0),o.widget.action?.type=="drawer"?(i.openBlock(),i.createBlock(x,{key:2,open:m.value.open,"onUpdate:open":p[0]||(p[0]=M=>m.value.open=M),title:o.widget.action?.title,placement:o.widget.action?.position,maskClosable:o.widget.action?.maskClosable,width:o.widget.action?.width,bodyStyle:{padding:0,overflow:!o.widget.action.component||o.widget.action.component=="iframe"?"hidden":"auto"}},{default:i.withCtx(()=>[!o.widget.action.component||o.widget.action.component=="iframe"?(i.openBlock(),i.createElementBlock("iframe",{key:0,class:"unione-iframe unione-btn-iframe",src:b.value},null,8,ka)):i.createCommentVNode("",!0)]),_:1},8,["open","title","placement","maskClosable","width","bodyStyle"])):i.createCommentVNode("",!0),o.widget.action?.type=="dialog"?(i.openBlock(),i.createBlock(S,{key:3,open:m.value.open,"onUpdate:open":p[1]||(p[1]=M=>m.value.open=M),title:o.widget.action?.title,width:o.widget.action?.width,maskClosable:o.widget.action?.maskClosable,centered:"",footer:null},{default:i.withCtx(()=>[!o.widget.action.component||o.widget.action.component=="iframe"?(i.openBlock(),i.createElementBlock("iframe",{key:0,class:"unione-iframe unione-btn-iframe",src:b.value,style:i.normalizeStyle({height:o.widget.action?.height?o.widget.action?.height+"px":""})},null,12,ba)):i.createCommentVNode("",!0)]),_:1},8,["open","title","width","maskClosable"])):i.createCommentVNode("",!0),i.createVNode(ci,{ref_key:"btnSetting",ref:f,preset:n.preset},null,8,["preset"])]),_:1},8,["class","model"])):i.createCommentVNode("",!0)}}}),[["__scopeId","data-v-b868da76"]]),wa={key:0,class:"unione-widget-empty-tip"},xa=ne(i.defineComponent({__name:"tabs",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1}},setup(o){const e=o,t=i.ref(),n=i.computed(()=>e.editor?.widget(e.wid)||e.widget);return(l,s)=>{const a=i.resolveComponent("a-tab-pane"),r=i.resolveComponent("a-tabs");return i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-layout-tabs"]),model:e.editor?.model},{default:i.withCtx(()=>[n.value?(i.openBlock(),i.createBlock(r,{key:0,activeKey:t.value,"onUpdate:activeKey":s[0]||(s[0]=d=>t.value=d)},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.value.chidlren,(d,h)=>(i.openBlock(),i.createBlock(a,{key:h,class:"unione-layout-tab-pane"},{tab:i.withCtx(()=>[i.createElementVNode("span",null,[d.icon?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(d.icon),{key:0})):i.createCommentVNode("",!0),i.createTextVNode(" "+i.toDisplayString(d.title),1)])]),default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(d.chidlren,(f,c)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(f.widget),{key:c,wid:f.wid,editor:e.editor,widget:f},null,8,["wid","editor","widget"]))),128)),!d.chidlren||!d.chidlren.length?(i.openBlock(),i.createElementBlock("div",wa,i.toDisplayString(d.emptyTips),1)):i.createCommentVNode("",!0)]),_:2},1024))),128))]),_:1},8,["activeKey"])):i.createCommentVNode("",!0)]),_:1},8,["model"])}}}),[["__scopeId","data-v-7b565c89"]]),va={class:"title"},Ca={class:"text"},Sa={key:0,class:"reactive"},Na={key:1,class:"opts"},Ba={class:"warp"},Oa=ne(i.defineComponent({__name:"section",props:i.mergeModels({title:{type:String,required:!1},icon:{type:String,required:!1},type:{type:String,required:!1},location:{type:String,default:"left"},reactive:{type:Boolean,default:!1},wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1}},{modelValue:{type:Boolean,default:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const e=o,t=i.computed(()=>e.editor?.widget(e.wid)||e.widget),n=i.computed(()=>t.value?.title||e.title),l=i.computed(()=>t.value?.icon||e.icon),s=i.computed(()=>t.value?.type||e.type),a=i.useModel(o,"modelValue");function r(){e.reactive&&(a.value=!a.value)}return(d,h)=>(i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-layout-section",a.value?"open":"close"]),model:e.editor?.model},{default:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["head",o.location,o.reactive&&"reactive"]),onClick:r},[i.createElementVNode("div",va,[s.value?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["type",s.value])},null,2)):i.createCommentVNode("",!0),l.value?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(l.value),{key:1,class:"icon"})):i.createCommentVNode("",!0),i.createElementVNode("span",Ca,i.toDisplayString(n.value),1)]),o.reactive?(i.openBlock(),i.createElementBlock("div",Sa,[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(a.value?"UpOutlined":"DownOutlined")))])):i.createCommentVNode("",!0),o.location=="left"?(i.openBlock(),i.createElementBlock("div",Na,[i.renderSlot(d.$slots,"opts",{},void 0,!0)])):i.createCommentVNode("",!0)],2),i.withDirectives(i.createElementVNode("div",Ba,[i.renderSlot(d.$slots,"default",{},void 0,!0)],512),[[i.vShow,a.value]])]),_:3},8,["class","model"]))}}),[["__scopeId","data-v-e75e9a84"]]),Va={class:"unione-props-setting unione-form-setting"},_a={class:"unione-form-btns"},Ma={key:0},Ta=["onClick"],Aa={class:"field-txt"},Ea=["onClick"],Ia={key:1,class:"field-txt"},Da=["onClick"],Pa={key:0,class:"field-txt"},Fa={key:3,class:"edit-field"},$a={key:0},Ra=["onClick"],La=ne(i.defineComponent({__name:"formSetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(o){const e=o,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:C})=>C+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"isForm",key:"isForm",width:"40px",align:"center"},{title:"详情",dataIndex:"isView",key:"isView",width:"40px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),n=i.computed(()=>{const C=e.editor.widget(e.wid)||{};return C.configs||(C.configs={}),C.configs.settings||(C.configs.settings={}),C.configs.settings.btns||(C.configs.settings.btns=[]),C}),l=i.computed(()=>(e.editor.dataModels()||[]).map(x=>({value:x.sn,label:x.title+"("+x.name+")"}))),s=i.computed(()=>{const C=n.value.configs.settings.btns,x=C.map(S=>S.name);if(!x.includes("save")){const S={title:"保存",type:"primary",index:0,visible:!0,name:"save"};C.splice(S.index,0,S)}if(!x.includes("submit")){const S={title:"提交",type:"primary",index:1,visible:!0,name:"submit"};let M=S.index||1;C.splice(M,0,S)}if(!x.includes("reset")){const S={title:"重置",type:"default",index:2,visible:!0,props:{danger:!0},name:"reset"};C.splice(S.index,0,S)}if(!x.includes("back")){const S={title:"返回",type:"default",index:3,visible:!0,name:"back"};C.splice(S.index,0,S)}return C}),a=i.ref(null);function r(C){a.value&&a.value.open(C,x=>{x.visible=!0,Object.keys(x).forEach(S=>{C[S]=x[S]}),n.value.configs.settings.btns.sort((S,M)=>{const T=S.index||1,E=M.index||1;return T-E}),n.value.configs.settings.btns=[...n.value.configs.btns]})}function d(){const C=n.value.configs.settings.btns.length+1;let x={title:"新增",name:"new_"+C,index:C,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{}};x.name="new_"+n.value.configs.settings.btns.length;const S=n.value.configs.settings.btns.filter(M=>M.name==x.name).length;S>0&&(x.name=x.name+S),n.value.configs.settings.btns.push(x),e.editor.widget(e.wid,n.value),a.value.open(x,M=>{Object.keys(M).forEach(T=>{x[T]=M[T]}),n.value.configs.btns=[...n.value.configs.btns]})}function h(C){const x=()=>{if(["save","submit","reset","back"].includes(C.name))C.visible=!1,n.value.configs.settings.btns=[...n.value.configs.settings.btns];else{const S=[];n.value.configs.settings.btns.forEach(M=>{M.name!=C.name&&S.push(M)}),n.value.configs.settings.btns=S}};J.Modal.confirm({title:"确认信息",content:"请确定删除该工具?",onOk:()=>{x()}})}const f=i.ref({visible:!1,field:{},props:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-textarea",label:"文本域"},{value:"a-input",label:"文本框"},{value:"a-checkbox",label:"多选框"},{value:"a-radio",label:"单选框"},{value:"a-input-number",label:"数值框"},{value:"a-select",label:"下拉框"},{value:"a-tree-select",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-switch",label:"开关"},{value:"a-slider",label:"滑块"}],widgetName:C=>{const x=f.value.widgets.filter(S=>S.value==C);return x[0]?x[0].label:C},toSetting:()=>{}}),c=i.ref({visible:!1,field:{},props:{},showInfo:C=>{let x="";return C.rules&&(x=C.rules.filter(S=>S.enable).length||""),x&&(x="("+x+")"),x},toSetting:()=>{const C=c.value.props,x={name:"range",trigger:C.trigger,whitespace:C.whitespace,message:C.rangeMessage};C.rangeMin!=null&&C.rangeMin!=null&&(x.min=C.rangeMin,x.enable=!0),C.rangeMax!=null&&C.rangeMax!=null&&(x.max=C.rangeMax,x.enable=!0);const S={name:"reg",trigger:C.trigger,whitespace:C.whitespace,message:C.regMessage};C.regExpress&&(S.pattern=C.regExpress,S.enable=!0),c.value.field.rules=[x,S],c.value.visible=!1,c.value.props={},console.log("rule",c.value.field.rules)}});function u(C){c.value.visible=!0,c.value.field=C;const x=C.rules||[],S={trigger:"change",whitespace:!0};x.forEach(M=>{M.name=="reg"&&(S.trigger=M.trigger,S.whitespace=M.whitespace,S.regExpress=M.pattern,S.regMessage=M.message),M.name=="range"&&(S.rangeMin=M.min,S.rangeMax=M.max,S.rangeMessage=M.message)}),c.value.props=S}const m=i.ref({title:"列头设置",prop:"isList",visible:!1,field:{},show:{},toSetting:()=>{m.value.visible=!1}});function b(C,x){const S=w.value.filter(T=>T.name==C.name);S.forEach(T=>{x!="isSort"?T[x]=!0:T[x]=!T[x]});const M=S[0];if(!(!M||x=="isSort")){switch(m.value.prop=x,m.value.field=C,M.show||(M.show={}),x){case"isQuery":M.show.query||(M.show.query={}),m.value.show=M.show.query,m.value.title=`查询设置/${C.title}(${C.name})`;break;case"isForm":M.show.form||(M.show.form={}),m.value.show=M.show.form,m.value.title=`表单设置/${C.title}(${C.name})`;break;case"isView":M.show.view||(M.show.view={}),m.value.show=M.show.view,m.value.title=`详情设置/${C.title}(${C.name})`;break;case"isList":M.show.list||(M.show.list={}),m.value.show=M.show.list,m.value.title=`列头设置/${C.title}(${C.name})`;break}m.value.visible=!0}}const y=i.ref({visible:!1,field:{},convert:{},optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],toAddOption:()=>{y.value.convert.options||(y.value.convert.options=[]),y.value.convert.options.push({label:"",value:""})},toDelOption:(C,x)=>{y.value.convert.options.splice(C,1)},toSetting:()=>{y.value.visible=!1}});function k(C){y.value.visible=!0,y.value.field=C,y.value.convert=C.convert||{}}const v=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),w=i.computed(()=>v.value.fields?.length?v.value.fields:[]),O={mounted:C=>C.focus()},g=i.ref({});function p(C,x){const S={};x=="convertName"?S[x]=C.convert?.type:S[x]=C[x]||"",g.value={},g.value[C.name]=S}function N(C,x){{g.value={};return}}function V(C,x){w.value.filter(M=>M.name==C.name).forEach(M=>{M[x]=!M[x]})}return(C,x)=>{const S=i.resolveComponent("a-divider"),M=i.resolveComponent("CloseOutlined"),T=i.resolveComponent("a-button"),E=i.resolveComponent("PlusOutlined"),I=i.resolveComponent("a-select"),L=i.resolveComponent("ToolOutlined"),A=i.resolveComponent("a-checkbox"),U=i.resolveComponent("a-table"),P=i.resolveComponent("a-select-option"),G=i.resolveComponent("a-form-item"),j=i.resolveComponent("a-form"),B=i.resolveComponent("a-modal"),F=i.resolveComponent("a-checkbox-group"),_=i.resolveComponent("a-input-number"),D=i.resolveComponent("a-input"),$=i.resolveComponent("a-col"),Q=i.resolveComponent("a-row");return i.openBlock(),i.createElementBlock("div",Va,[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[23]||(x[23]=[i.createTextVNode("按钮设置")])),_:1}),i.createElementVNode("div",_a,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,R=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:R.name,class:["btn",R.name,!R.visible&&"deleted"],type:R.visible?R.type:"default",size:R.size,ref_for:!0},R.props||{},{onClick:X=>r(R)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(R.title)+" ",1),R.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"btn-del",onClick:i.withModifiers(X=>h(R),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[R.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(R.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","btn-add"]),size:"small",onClick:x[0]||(x[0]=R=>d())},{default:i.withCtx(()=>[i.createVNode(E)]),_:1})]),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[24]||(x[24]=[i.createTextVNode("表单设置")])),_:1}),x[36]||(x[36]=i.createTextVNode(" 数据模型:")),i.createVNode(I,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":x[1]||(x[1]=R=>n.value.dataModel=R)},null,8,["options","value"]),i.createVNode(U,{columns:t.value,"data-source":w.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:R})=>[["widget","rules","convertName"].includes(R.key)?(i.openBlock(),i.createElementBlock("span",Ma,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(R.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:R,text:X,record:Z})=>[["rules"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!c.value.showInfo(Z)&&"empty"]),onClick:ge=>u(Z)},[i.createElementVNode("span",Aa,i.toDisplayString(c.value.showInfo(Z)),1),c.value.showInfo(Z)?(i.openBlock(),i.createBlock(T,{key:0,type:"link"},{default:i.withCtx(()=>x[25]||(x[25]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Ta)):["widget"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!g.value[Z.name]||!Object.keys(g.value[Z.name]).includes(R.dataIndex))&&!X&&"empty"]),onClick:ge=>p(Z,R.dataIndex)},[g.value[Z.name]&&Object.keys(g.value[Z.name]).includes(R.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(I,{key:0,value:Z[R.dataIndex],"onUpdate:value":ge=>Z[R.dataIndex]=ge,options:f.value.widgets,onBlur:x[2]||(x[2]=ge=>N())},null,8,["value","onUpdate:value","options"])),[[O]]):(i.openBlock(),i.createElementBlock("span",Ia,i.toDisplayString(f.value.widgetName(X)),1))],10,Ea)):["convertName"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!g.value[Z.name]||!Object.keys(g.value[Z.name]).includes(R.dataIndex))&&!Z.convert?.type&&"empty"]),onClick:ge=>p(Z,R.dataIndex)},[g.value[Z.name]&&Object.keys(g.value[Z.name]).includes(R.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(I,{key:0,value:Z[R.dataIndex],"onUpdate:value":ge=>Z[R.dataIndex]=ge,options:[{value:"dict",label:"字典"},{value:"option",label:"静态"}],onBlur:x[3]||(x[3]=ge=>N())},null,8,["value","onUpdate:value"])),[[O]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[Z.convert?.type?(i.openBlock(),i.createElementBlock("span",Pa,i.toDisplayString(Z.convert.type=="dict"?"字典":"静态"),1)):i.createCommentVNode("",!0),Z.convert?.type?(i.openBlock(),i.createBlock(T,{key:1,type:"link",onClick:i.withModifiers(ge=>k(Z),["stop"])},{default:i.withCtx(()=>x[26]||(x[26]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,Da)):["isForm","isView"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",Fa,[i.createVNode(A,{checked:Z[R.dataIndex],onClick:ge=>V(Z,R.dataIndex)},null,8,["checked","onClick"]),i.createVNode(T,{type:"link",onClick:ge=>b(Z,R.dataIndex)},{default:i.withCtx(()=>x[27]||(x[27]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(B,{visible:f.value.visible,"onUpdate:visible":x[5]||(x[5]=R=>f.value.visible=R),title:"控件设置",onOk:f.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:f.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[f.value.field.widget=="a-select"?(i.openBlock(),i.createBlock(G,{key:0,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(I,{value:f.value.props.mode,"onUpdate:value":x[4]||(x[4]=R=>f.value.props.mode=R),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(P,{value:"multiple"},{default:i.withCtx(()=>x[28]||(x[28]=[i.createTextVNode("多选")])),_:1}),i.createVNode(P,{value:"tags"},{default:i.withCtx(()=>x[29]||(x[29]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(B,{visible:c.value.visible,"onUpdate:visible":x[13]||(x[13]=R=>c.value.visible=R),title:"规则设置",onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:c.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[30]||(x[30]=[i.createTextVNode("基本设置")])),_:1}),i.createVNode(G,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(F,{value:c.value.props.trigger,"onUpdate:value":x[6]||(x[6]=R=>c.value.props.trigger=R),options:["change","blur"]},null,8,["value"])]),_:1}),c.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(G,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(A,{value:c.value.props.whitespace,"onUpdate:value":x[7]||(x[7]=R=>c.value.props.whitespace=R),checked:c.value.props.whitespace},{default:i.withCtx(()=>x[31]||(x[31]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["value","checked"])]),_:1})),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[32]||(x[32]=[i.createTextVNode("数值区间")])),_:1}),i.createVNode(G,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(_,{value:c.value.props.rangeMin,"onUpdate:value":x[8]||(x[8]=R=>c.value.props.rangeMin=R)},null,8,["value"]),x[33]||(x[33]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(_,{value:c.value.props.rangeMax,"onUpdate:value":x[9]||(x[9]=R=>c.value.props.rangeMax=R)},null,8,["value"])]),_:1}),i.createVNode(G,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.rangeMessage,"onUpdate:value":x[10]||(x[10]=R=>c.value.props.rangeMessage=R)},null,8,["value"])]),_:1}),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[34]||(x[34]=[i.createTextVNode("正则验证")])),_:1}),i.createVNode(G,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.regExpress,"onUpdate:value":x[11]||(x[11]=R=>c.value.props.regExpress=R)},null,8,["value"])]),_:1}),i.createVNode(G,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.regMessage,"onUpdate:value":x[12]||(x[12]=R=>c.value.props.regMessage=R)},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(B,{visible:m.value.visible,"onUpdate:visible":x[20]||(x[20]=R=>m.value.visible=R),title:m.value.title,onOk:m.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:m.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(G,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(_,{value:m.value.show.index,"onUpdate:value":x[14]||(x[14]=R=>m.value.show.index=R)},null,8,["value"])]),_:1}),["isQuery"].includes(m.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(G,{key:0,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.width,"onUpdate:value":x[15]||(x[15]=R=>m.value.show.width=R)},null,8,["value"])]),_:1})),["isForm","isView"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:1,label:"标题宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.labelWidth,"onUpdate:value":x[16]||(x[16]=R=>m.value.show.labelWidth=R)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isForm","isView"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:2,label:"控件宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.valueWidth,"onUpdate:value":x[17]||(x[17]=R=>m.value.show.valueWidth=R)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:3,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(I,{value:m.value.show.fixed,"onUpdate:value":x[18]||(x[18]=R=>m.value.show.fixed=R),options:[{value:"",label:"无"},{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:4,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(I,{value:m.value.show.align,"onUpdate:value":x[19]||(x[19]=R=>m.value.show.align=R),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(B,{visible:y.value.visible,"onUpdate:visible":x[22]||(x[22]=R=>y.value.visible=R),title:y.value.convert.type=="dict"?"字典设置":"选项设置",onOk:y.value.toSetting},{default:i.withCtx(()=>[y.value.convert.type!="dict"?(i.openBlock(),i.createElementBlock("div",$a,[i.createVNode(T,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:y.value.toAddOption},{default:i.withCtx(()=>x[35]||(x[35]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(U,{columns:y.value.optionColumn,"data-source":y.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:R,record:X,index:Z})=>[R.dataIndex==="label"?(i.openBlock(),i.createBlock(D,{key:0,value:X.label,"onUpdate:value":ge=>X.label=ge,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),R.dataIndex==="value"?(i.openBlock(),i.createBlock(D,{key:1,value:X.value,"onUpdate:value":ge=>X.value=ge,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),R.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:ge=>y.value.toDelOption(Z,X)},"删除",8,Ra)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])])):i.createCommentVNode("",!0),y.value.convert.type=="dict"?(i.openBlock(),i.createBlock(j,{key:1,model:y.value.convert,name:"basic","label-col":{span:8},"wrapper-col":{span:16},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(Q,{type:"flex",style:{width:"100%"}},{default:i.withCtx(()=>[i.createVNode($,{span:24,order:1},{default:i.withCtx(()=>[i.createVNode(G,{label:"字典名称:"},{default:i.withCtx(()=>[i.createVNode(D,{value:y.value.convert.dict,"onUpdate:value":x[21]||(x[21]=R=>y.value.convert.dict=R)},null,8,["value"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):i.createCommentVNode("",!0)]),_:1},8,["visible","title","onOk"]),i.createVNode(ci,{ref_key:"btnSetting",ref:a},null,512)])}}}),[["__scopeId","data-v-c0f75bb9"]]),ja=ne(i.defineComponent({__name:"form",props:{editor:{type:Object,required:!1},widget:{type:Object,required:!1},form:{type:Object,required:!1}},setup(o,{expose:e}){const t=o,n=i.ref(!1),l=i.ref(),s=i.ref({}),a=i.ref(null);i.onMounted(()=>{if(d.value.dsn){const w=r.value.dataManager();d.value.primary&&w.psn(d.value.dsn),a.value.setDisabled=v,a.value.getValue=u,a.value.setValue=m,a.value.reset=b,l.value=w.useForm(d.value.dsn,a.value,O=>{s.value=O.body||{}})}t.editor||r.value.loadConfig({widgets:h.value}),t.form?.model&&r.value.setModel(t.form.model),y()});const r=i.computed(()=>t.editor||new ct),d=i.computed(()=>t.widget||t.form||{}),h=i.computed(()=>{let w=d.value.widgets||[];return!w.length&&t.form?.fields&&(w=t.form.fields),w.forEach(O=>{O.widget||(O.widget="unione-form-item"),O.control||(O.control="a-input")}),w}),f=i.inject("pageSetting"),c=i.computed(()=>d.value.setting||f?.form||{});i.provide("formSetting",c.value);function u(){return s.value}function m(w){s.value=w,y()}function b(){s.value={},y()}function y(){const w=O=>{O.widget=="unione-form-item"&&O.name&&(O.value!=null&&O.value!=null&&O.value!=""||O.value==0)&&(s.value[O.name]==null||s.value[O.name]==null||s.value[O.name]=="")&&(s.value[O.name]=O.value),O.widgets?.forEach(g=>{w(g)})};h.value.forEach(O=>{w(O)})}function k(){return a.value.validate()}function v(w=!0){n.value=w}return e({validate:k,getValue:u,setValue:m,reset:b,setDisabled:v}),(w,O)=>{const g=i.resolveComponent("a-form");return i.openBlock(),i.createBlock(ht,{class:"unione-form-widget","setting-title":"表单设置",model:r.value.model.value},i.createSlots({default:i.withCtx(()=>[i.createVNode(g,{ref_key:"formObj",ref:a,model:s.value,class:i.normalizeClass(["unione-form",r.value.model.value,"form-layout-col-"+(c.value.showColumn||3)])},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.value,(p,N)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(p.widget),{key:N,widget:p,editor:r.value,value:s.value[p.name],"onUpdate:value":V=>s.value[p.name]=V,disabled:n.value,formValue:s.value},null,40,["widget","editor","value","onUpdate:value","disabled","formValue"]))),128))]),_:1},8,["model","class"])]),_:2},[o.editor&&d.value.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(La,{wid:d.value.wid,editor:o.editor},null,8,["wid","editor"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-9a034019"]]);function yl(o,e=!1){const t=Ie();if(!o)return Promise.reject("字典名称不能为空");const n=localStorage.getItem("UNIONE-DICT-"+o);return n&&e==!1?Promise.resolve(JSON.parse(n)):(t.isDebug&&console.log("进入:加载字典数据方法,dict name:"+o+",force:"+e),new Promise((l,s)=>{K.axios.admin({url:"/api/system/dict/load/"+o}).then(a=>{if(a.success){const r=a.body.filter(d=>d.dictName!=d.dictKey);r.forEach(d=>{d.value=d.dictKey,d.label=d.dictValue}),r.length?(localStorage.setItem("UNIONE-DICT-"+o,JSON.stringify(r)),l(r)):s("字典加载失败,dict:"+o+",字典项列表为空")}else t.isDebug&&console.error("字典加载失败,dict:"+o,a),s("字典加载失败,dict:"+o+",error:"+a.message)})}))}async function wl(o,e){const t=Ie();if(e==null||e==null||e=="undefined"||!(e+"").length)return Promise.reject("字典key为空");const n=await yl(o),l=n.filter(s=>s.dictKey==e);return l.length>0?Promise.resolve(l[0]):(t.isDebug&&console.log("字典项匹配失败,name:"+o+",key:"+e+"options:",n),Promise.reject("字典项匹配失败,name:"+o+",key:"+e))}async function za(o,e){const t=await wl(o,e);return Promise.resolve(t.dictValue)}const xl={load:yl,getLabel:za,getOption:wl};class Ke{convertObj;config;options;constructor(e){(!e||!e.types)&&console.error("转换器定义不能为空,type不能为空",e),e.valueField||(e.valueField="id"),e.labelField||(e.labelField="title"),this.convertObj=e,this.options=e.options||[],this.config=Ie()}load(e,t=!1){return!(e==null||e==null||e=="undefined"||!(e+"").length)&&this.options?.length&&this.options.filter(n=>n.value==e).length?Promise.resolve(this.options):this.convertObj.types=="dict"?new Promise((n,l)=>{if(!this.convertObj.dictName){l("字典名称不能为空,id:"+this.convertObj.id);return}xl.load(this.convertObj.dictName,t).then(s=>{this.options=s,typeof e=="number"&&this.options.forEach(a=>{a.value=parseInt(a.value)}),n(this.options)})}):this.convertObj.types=="option"?(this.options=this.convertObj.options||[],this.convertObj.options?.length?Promise.resolve(this.convertObj.options):(this.config.isDebug&&console.error("静态转换器选项为空,id:"+this.convertObj.id,this.convertObj),Promise.reject("静态转换器选项为空,id:"+this.convertObj.id))):!this.convertObj.id&&this.convertObj.types!="local"?Promise.reject("转换器id不能为空,type:"+this.convertObj.types):new Promise((n,l)=>{const s=this.convertObj.params||{body:{}};this.convertObj.pidField&&(s.pid=-1);const a=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:a,data:s,method:"POST"}).then(r=>{r.success?(this.options=r.body,this.$processOptions(this.options),typeof e=="number"&&this.options.forEach(d=>{d.value=parseInt(d.value)}),e==null||e==null||e=="undefined"||!(e+"").length?this.options.length?n(this.options):(this.config.isDebug&&console.error("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id,r),l("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id)):this.options.filter(h=>h.value==e).length?n(this.options):(s.body||(s.body={}),s.body[this.convertObj.valueField||"id"]=e,K.axios.admin({url:a,data:s,method:"POST"}).then(h=>{if(h.success){const f={};this.options.forEach(c=>{f[e]=!0}),h.body.forEach(c=>{f[c.value]||this.options.push(c)}),n(this.options)}else l("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id)}))):(this.config.isDebug&&console.error("数据选项加载失败,type:"+this.convertObj.types+",id:"+this.convertObj.id,r),l("数据选项加载失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",error:"+r.message))})})}convert(e){if(e==null||e==null||e=="undefined"||!(e+"").length)return Promise.reject("value为空");if(this.convertObj.types=="dict")return this.convertObj.dictName?xl.getLabel(this.convertObj.dictName,e):Promise.reject("字典名称不能为空");if(this.convertObj.types=="option"){if(this.convertObj.options?.length){const t=this.convertObj.options.filter(n=>n.value==e);return t.length?Promise.resolve(t[0].label):(this.config.isDebug&&console.error("静态转换器选项匹配失败,id:"+this.convertObj.id+",value:"+e,this.convertObj),Promise.reject("静态转换器选项匹配失败,id:"+this.convertObj.id+",value:"+e))}return Promise.reject("静态转换器选项为空,id:"+this.convertObj.id)}if(this.options?.length){const t=this.options.filter(n=>n.value==e);if(t.length)return Promise.resolve(t[0].label)}return new Promise((t,n)=>{this.load(e).then(l=>{const s=l.filter(a=>a.value==e);if(s.length)return t(s[0].label);n()})})}children(e=-1){return this.config.isDebug&&console.log("进入:加载下级数据项方法,id:"+this.convertObj.id+",type:"+this.convertObj.types+",pid:"+e),this.convertObj.pidField?this.convertObj.types=="dict"||this.convertObj.types=="option"?Promise.reject("字典/静态转换器不支持该方法,type:"+this.convertObj.types+",id:"+this.convertObj.id):new Promise((n,l)=>{const s=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:s,data:e,method:"POST"}).then(a=>{a.success?(this.$processOptions(a.body),this.options=[...this.options,...a.body],n(a.body)):(this.config.isDebug&&console.error("加载下级数据项失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",pid:"+e,a),l("加载下级数据项失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",pid:"+e+",error:"+a.message))})}):Promise.reject("转换器未设置parentField,id:"+this.convertObj.id)}search(e){return this.config.isDebug&&console.log("进入:搜索数据选项方法,id:"+this.convertObj.id+",type:"+this.convertObj.types+",keywords:"+e),this.convertObj.types=="dict"||this.convertObj.types=="option"?Promise.resolve(this.options.filter(t=>t.label.indexOf(e)>=0)):new Promise(t=>{const n=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:n,data:{body:{keywords:e}},method:"POST"}).then(l=>{l.success?(this.$processOptions(l.body),t(l.body)):t([])})})}$processOptions(e){return this.convertObj.types=="local"&&e.forEach(t=>{this.convertObj.idField&&(t.id=t[this.convertObj.idField]),this.convertObj.pidField&&(t.pid=t[this.convertObj.pidField]),t.value=t[this.convertObj.valueField||"id"],t.label=t[this.convertObj.labelField||"title"]}),e}}const qa=["innerHTML"],Ua={key:2,class:"text-view"},Wa=ne(i.defineComponent({__name:"formItem",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},formValue:{type:Object,required:!0},disabled:{type:Boolean,defualt:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(o){const e=o,t=i.useModel(o,"value"),n=i.inject("formSetting");i.onMounted(()=>{s.value.value!=null&&typeof s.value.value<"u"&&(e.formValue[s.value.name]==null||e.formValue[s.value.name]==null||typeof e.formValue[s.value.name]>"u")&&(t.value=s.value.value,s.value.widget=="unione-check-box"&&(Array.isArray(s.value.value)||(typeof s.value.value=="string"?t.value=s.value.value.split(","):t.value=[s.value.value])))});const l=i.ref({}),s=i.computed(()=>{const k=e.editor?.widget(e.wid)||e.widget||{};return k.event&&Object.keys(k.event).forEach(v=>{const w=k.event[v];w&&(l.value[v]=null,typeof w=="function"?l.value[v]=w:w.enable&&w.scriptText&&(l.value[v]=new Function("value","ctx",w.scriptText)))}),k}),a=i.computed(()=>!(l.value.visible&&l.value.visible(e.formValue[s.value.name],e.formValue)==!1)),r=i.computed(()=>l.value.title&&l.value.title(e.formValue[s.value.name],e.formValue)||s.value.title),d=i.computed(()=>l.value.change&&l.value.change(e.formValue[s.value.name],e.formValue)||s.value.change),h=i.ref({}),f=i.computed(()=>{const k=[],v=s.value.rule||{};let w=s.value.props?.required||s.value.required;if(l.value.required&&(w=l.value.required(e.formValue[s.value.name],e.formValue)),w&&k.push({required:!0,whitespace:v?.whitespace||!1,trigger:v?.trigger||n.ruleTrigger||"change",validator:(O,g)=>(v?.whitespace&&g&&typeof g=="string"&&(g=g.trim()),g!=null&&g!=null&&(g+"").replace(/\s+/g,"").length>0?Promise.resolve():Promise.reject(r.value+"不能为空!"))}),v.advance&&h.value[v.advance]){const O=h.value[v.advance];k.push({pattern:O.pattern,message:O.message||"表单验证不通过!",trigger:v.trigger||n.ruleTrigger||"change"})}return v.regExpress&&k.push({pattern:v.regExpress,message:v.regMessage||"表单验证不通过!",trigger:v.trigger||n.ruleTrigger||"change"}),s.value.dataLen&&k.push({validator:(O,g)=>g&&(g+"").length>s.value.dataLen?Promise.reject("最大长度["+s.value.dataLen+"],当前:["+(g+"").length+"]"):Promise.resolve(),trigger:v?.trigger||n.ruleTrigger||"change"}),k}),c=i.computed(()=>{const k=s.value.props||{};if(s.value.control=="a-input-number"){const v=s.value.rule||{};v.rangeMin!=null&&v.rangeMin!=null&&(k.min=v.rangeMin),v.rangeMax!=null&&v.rangeMax!=null&&(k.max=v.rangeMax)}return s.value.control=="a-date-picker"&&s.value.view?.dataFormat&&(k.format=s.value.view.dataFormat,k.valueFormat=s.value.view.dataFormat),s.value.required&&(k.required=s.value.required),k}),u=i.computed(()=>{const k=s.value.css||{},v=["form-item-"+s.value.name];return k.cssName&&v.push(k.cssName),n.platform=="app"?k.cssName?typeof k.cssName=="string"&&k.cssName.indexOf("all-line")<0&&v.push("all-line"):v.push("all-line"):s.value.view?.width&&(s.value.view.width>=3?(!k.cssName||typeof k.cssName=="string"&&k.cssName.indexOf("all-line")<0)&&v.push("all-line"):s.value.view.width==2&&v.push("2in-line")),v}),m=i.computed(()=>{const k=n.showColumn||3;let v=s.value.view?.labelWidth||n.labelWidth||9;return s.value.css?.cssName&&k>1&&typeof s.value.css.cssName=="string"&&s.value.css.cssName.indexOf("all-line")>=0?{span:Math.round(v/k)}:s.value.view?.width>=3&&k>1?{span:Math.round(v/k)}:{span:v}}),b=i.computed(()=>{const k=n.showColumn||3;let v=s.value.view?.valueWidth||n.valueWidth||19;return s.value.css?.cssName&&k>1&&u.value.includes("all-line")?{}:{span:v}}),y=i.ref();return i.watch(t,()=>{t.value&&e.editor?.model.value=="view"&&s.value.convert&&new Ke(s.value.convert).convert(t.value.toString()).then(k=>{y.value=k})}),(k,v)=>{const w=i.resolveComponent("a-form-item");return i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-form-item",u.value]),style:i.normalizeStyle(s.value.css?.cssText)},{default:i.withCtx(()=>[a.value?(i.openBlock(),i.createBlock(w,{key:0,label:r.value,name:s.value.name,labelCol:m.value,wrapperCol:b.value,required:s.value.props?.required,rules:f.value,help:(!e.editor||e.editor.model.value!="view")&&s.value.props?.help,tooltip:s.value.props?.tooltip},{default:i.withCtx(()=>[!o.editor||o.editor.model.value!="view"?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.value.control||"a-input"),i.mergeProps({key:0,wid:s.value.wid,widget:s.value,editor:e.editor,disabled:o.disabled,onChange:d.value,value:t.value,"onUpdate:value":v[0]||(v[0]=O=>t.value=O)},c.value,{style:s.value.css?.props}),null,16,["wid","widget","editor","disabled","onChange","value","style"])):s.value.view=="html"?(i.openBlock(),i.createElementBlock("div",{key:1,class:"text-view",innerHTML:y.value?y.value:t.value},null,8,qa)):(i.openBlock(),i.createElementBlock("div",Ua,i.toDisplayString(y.value?y.value:t.value),1))]),_:1},8,["label","name","labelCol","wrapperCol","required","rules","help","tooltip"])):i.createCommentVNode("",!0)]),_:1},8,["class","style"])}}}),[["__scopeId","data-v-c8c92250"]]);function tn(o,e=350){let t=null;return n=>{clearTimeout(t),t=setTimeout(()=>{o(n)},e)}}const Ha=ne(i.defineComponent({__name:"selectBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(o){Ie();const e=o,t=i.useModel(o,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]),s=i.computed(()=>(d.value.convert||e.convert||{}).search||!1),a=tn(f=>{h.value.search(f).then(c=>{n.value=c})},500);i.onMounted(()=>{h.value.load(t.value).then(f=>{n.value=f})});const r=i.ref({}),d=i.computed(()=>{const f=e.editor?.widget(e.wid)||e.widget||{};return f.event&&Object.keys(f.event).forEach(c=>{const u=f.event[c];r.value[c]=null,u.enable&&u.scriptText&&(r.value[c]=new Function("value","ctx",u.scriptText))}),f}),h=i.computed(()=>{const f=d.value.convert||e.convert||{};return new Ke(f)});return i.watch(t,()=>{t.value&&h.value.load(t.value).then(f=>{n.value=f})}),i.watch(()=>d.value.convert||e.convert||{},()=>{h.value.load().then(f=>{n.value=f})}),(f,c)=>{const u=i.resolveComponent("a-select");return i.openBlock(),i.createBlock(u,{class:"unione-form-select",options:l.value,showSearch:s.value,value:t.value,"onUpdate:value":c[0]||(c[0]=m=>t.value=m),onSearch:i.unref(a)},null,8,["options","showSearch","value","onSearch"])}}}),[["__scopeId","data-v-d885ca4f"]]),Ka=ne(i.defineComponent({__name:"switchBox",props:i.mergeModels({editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(o){const e=o,t=i.useModel(o,"value"),n=i.ref({});i.onMounted(()=>{a.value?.load(t.value).then(r=>{r.forEach(d=>{d.value&&(d.value=="1"||d.value=="true"||d.value=="TRUE")?(n.value.checkedChildren=d.label,d.value=="true"||d.value=="TRUE"?n.value.checkedValue=!0:n.value.checkedValue=1):(n.value.unCheckedChildren=d.label,d.value=="false"||d.value=="FALSE"?n.value.unCheckedValue=!1:n.value.unCheckedValue=0)})})});const l=i.ref({}),s=i.computed(()=>{const r=e.widget||{};return r.event&&Object.keys(r.event).forEach(d=>{const h=r.event[d];l.value[d]=null,h.enable&&h.scriptText&&(l.value[d]=new Function("value","ctx",h.scriptText))}),r}),a=i.computed(()=>{const r=s.value.convert||e.convert;return r?new Ke(r):null});return(r,d)=>{const h=i.resolveComponent("a-switch");return i.openBlock(),i.createBlock(h,i.mergeProps({class:"unione-form-switch"},n.value,{checked:t.value,"onUpdate:checked":d[0]||(d[0]=f=>t.value=f)}),null,16,["checked"])}}}),[["__scopeId","data-v-a56d945e"]]),Qa=ne(i.defineComponent({__name:"radioBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(o){const e=o,t=i.useModel(o,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]);i.onMounted(()=>{r.value.load(t.value||a.value.value).then(d=>{n.value=d})});const s=i.ref({}),a=i.computed(()=>{const d=e.editor?.widget(e.wid)||e.widget||{};return d.event&&Object.keys(d.event).forEach(h=>{const f=d.event[h];s.value[h]=null,f.enable&&f.scriptText&&(s.value[h]=new Function("value","ctx",f.scriptText))}),d}),r=i.computed(()=>{const d=a.value.convert||e.convert||{};return new Ke(d)});return(d,h)=>{const f=i.resolveComponent("a-radio-group");return i.openBlock(),i.createBlock(f,{class:"unione-form-radio",options:l.value,value:t.value,"onUpdate:value":h[0]||(h[0]=c=>t.value=c)},null,8,["options","value"])}}}),[["__scopeId","data-v-761054e0"]]),Ga=ne(i.defineComponent({__name:"checkBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(o){const e=o,t=i.useModel(o,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]);i.onMounted(()=>{r.value.load(t.value||a.value.value).then(d=>{n.value=d})});const s=i.ref({}),a=i.computed(()=>{const d=e.editor?.widget(e.wid)||e.widget||{};return d.event&&Object.keys(d.event).forEach(h=>{const f=d.event[h];s.value[h]=null,f.enable&&f.scriptText&&(s.value[h]=new Function("value","ctx",f.scriptText))}),d}),r=i.computed(()=>{const d=a.value.convert||e.convert||{};return new Ke(d)});return(d,h)=>{const f=i.resolveComponent("a-checkbox-group");return i.openBlock(),i.createBlock(f,{class:"unione-form-checkbox",options:l.value,value:t.value,"onUpdate:value":h[0]||(h[0]=c=>t.value=c)},null,8,["options","value"])}}}),[["__scopeId","data-v-e2f0f7fc"]]),Ya=ne(i.defineComponent({__name:"pwdBox",props:{value:{},valueModifiers:{}},emits:["update:value"],setup(o){const e=i.ref(),t=i.useModel(o,"value");return i.watch(()=>e.value,()=>{e.value?t.value=K.utils.sm2Encrypt(e.value):t.value=""}),(n,l)=>{const s=i.resolveComponent("a-input-password");return i.openBlock(),i.createBlock(s,{class:"unione-form-password",value:e.value,"onUpdate:value":l[0]||(l[0]=a=>e.value=a)},null,8,["value"])}}}),[["__scopeId","data-v-4515a2af"]]),Xa={class:"unione-props-setting unione-query-setting"},Ja={class:"unione-query-opts"},Za={key:0},er=["onClick"],tr={key:1},ir={key:1,class:"edit-field"},nr=["onClick"],lr=ne(i.defineComponent({__name:"querySetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(o){const e=o,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:O})=>O+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"查询",dataIndex:"isQuery",key:"isQuery",width:"30px",align:"center"},{title:"查询类型",dataIndex:"queryType",key:"queryType",width:"55px",align:"center"},{title:"显示顺序",dataIndex:"showIndex",key:"showIndex",width:"55px",align:"center"}]),n=i.computed(()=>{const O=e.editor.widget(e.wid)||{};return O.configs||(O.configs={}),O.configs.btns||(O.configs.btns=[]),O}),l=i.computed(()=>(e.editor.dataModels()||[]).map(g=>({value:g.sn,label:g.title+"("+g.name+")"}))),s=i.computed(()=>{const O=[],g=[];return n.value.configs.btns||(n.value.configs.btns=[]),n.value.configs.btns.forEach(p=>{O.push(p),g.push(p.name)}),g.includes("query")||O.splice(0,0,{visible:!0,name:"query",title:"搜索",type:"primary"}),g.includes("reset")||O.splice(1,0,{visible:!0,name:"reset",title:"重置",type:"default"}),g.includes("reset")||O.splice(1,0,{visible:!0,name:"advanced",title:"高级搜索",type:"default"}),O.sort((p,N)=>{const V=p.index||1,C=N.index||1;return V-C}),O}),a=i.ref(null);function r(O){a.value&&a.value.open(O,g=>{g.visible=!0,Object.keys(g).forEach(p=>{O[p]=g[p]}),n.value.configs.btns.sort((p,N)=>{const V=p.index||1,C=N.index||1;return V-C}),n.value.configs.btns=[...n.value.configs.btns]})}function d(){const O=n.value.configs.btns.length+1;let g={title:"新增",name:"new_"+O,size:"default",index:O,visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{clickScript:"",titleScript:"",disableScript:"",visibleScript:""}};n.value.configs.btns.push(g),e.editor.widget(e.wid,n.value),a.value.open(g,p=>{Object.keys(p).forEach(N=>{g[N]=p[N]}),n.value.configs.btns=[...n.value.configs.btns]})}function h(O){const g=()=>{if(["query","reset","advanced"].includes(O.name))O.visible=!1,n.value.configs.btns=[...n.value.configs.btns];else{const p=[];n.value.configs.btns.forEach(N=>{N.name!=O.name&&p.push(N)}),n.value.configs.btns=p}};J.Modal.confirm({title:"确认信息",content:"请确定删除该操作?",onOk:()=>{g()}})}const f=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),c=i.computed(()=>f.value.fields?.length?f.value.fields:[]),u={mounted:O=>O.focus()},m=i.ref({});function b(){const O=Object.keys(m.value);if(O.length)for(let g in O){const p=c.value.filter(N=>N.name==g);if(p&&p[0]){let N=m.value[g];Object.keys(N).forEach(V=>{if(V=="showIndex"){const C=p[0].show?.query||{};p[0].show||(p[0].show={}),p[0].show.query={...C,index:N[V]}}else p[0][V]=N[V]})}}m.value={}}function y(O,g){b();const p={};p[g]=O[g]||"",g=="showIndex"&&(p[g]=O.show?.query?.index),m.value[O.name]=p}function k(O,g){if(!O||!g){m.value={};return}const p=m.value[O.name][g];if(g=="showIndex"){const N=O.show?.query||{};O.show||(O.show={}),O.show.query={...N,index:p}}else O[g]=p;m.value={}}function v(O,g){c.value.filter(N=>N.name==O.name).forEach(N=>{N[g]=!N[g]})}const w=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:O=>{const g=w.value.options.filter(p=>p.value==O);return g[0]?g[0].label:O}});return(O,g)=>{const p=i.resolveComponent("a-divider"),N=i.resolveComponent("CloseOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("PlusOutlined"),x=i.resolveComponent("a-select"),S=i.resolveComponent("ToolOutlined"),M=i.resolveComponent("a-checkbox"),T=i.resolveComponent("a-input-number"),E=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",Xa,[i.createVNode(p,{orientation:"left"},{default:i.withCtx(()=>g[3]||(g[3]=[i.createTextVNode("查询按钮")])),_:1}),i.createElementVNode("div",Ja,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,I=>(i.openBlock(),i.createBlock(V,i.mergeProps({key:I.name,class:["btn",I.name,!I.visible&&"deleted"],type:I.visible?I.type:"default",size:I.size||"default",ref_for:!0},I.props||{},{onClick:L=>r(I)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(I.title)+" ",1),I.visible?(i.openBlock(),i.createBlock(N,{key:0,class:"btn-del",onClick:i.withModifiers(L=>h(I),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[I.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(I.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(V,{class:i.normalizeClass(["btn","btn-add"]),onClick:g[0]||(g[0]=I=>d()),size:"small"},{default:i.withCtx(()=>[i.createVNode(C)]),_:1})]),i.createVNode(p,{orientation:"left"},{default:i.withCtx(()=>g[4]||(g[4]=[i.createTextVNode("查询字段")])),_:1}),g[5]||(g[5]=i.createTextVNode(" 数据模型:")),i.createVNode(x,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":g[1]||(g[1]=I=>n.value.dataModel=I)},null,8,["options","value"]),i.createVNode(E,{columns:t.value,"data-source":c.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:I})=>[["showIndex","queryType"].includes(I.key)?(i.openBlock(),i.createElementBlock("span",Za,[i.createVNode(S),i.createTextVNode(" "+i.toDisplayString(I.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:I,text:L,record:A})=>[["queryType"].includes(I.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!m.value[A.name]||!Object.keys(m.value[A.name]).includes(I.dataIndex))&&!L&&"empty"]),onClick:U=>y(A,I.dataIndex)},[m.value[A.name]&&Object.keys(m.value[A.name]).includes(I.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(x,{key:0,value:A[I.dataIndex],"onUpdate:value":U=>A[I.dataIndex]=U,allowClear:!0,options:w.value.options,onBlur:g[2]||(g[2]=U=>k())},null,8,["value","onUpdate:value","options"])),[[u]]):(i.openBlock(),i.createElementBlock("span",tr,i.toDisplayString(w.value.showLabel(L)),1))],10,er)):["isQuery"].includes(I.dataIndex)?(i.openBlock(),i.createElementBlock("div",ir,[i.createVNode(M,{checked:A[I.dataIndex],onClick:U=>v(A,I.dataIndex)},null,8,["checked","onClick"])])):I.dataIndex=="showIndex"?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!m.value[A.name]||!Object.keys(m.value[A.name]).includes(I.dataIndex))&&!L&&"empty"]),onClick:U=>y(A,I.dataIndex)},[m.value[A.name]&&Object.keys(m.value[A.name]).includes(I.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(T,{key:0,value:m.value[A.name][I.dataIndex],"onUpdate:value":U=>m.value[A.name][I.dataIndex]=U,onBlur:U=>k(A,I.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[u]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(A.show?.query?.index||" "),1)],64))],10,nr)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(ci,{ref_key:"btnSetting",ref:a},null,512)])}}}),[["__scopeId","data-v-ce575063"]]),sr={class:"query-btn"},or={class:"btn-advanced-overlay"},vl=ne(i.defineComponent({__name:"queryForm",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},fields:{type:Array},params:{type:Object,default(){return{}}}},emits:["query","reset","btnClick"],setup(o,{emit:e}){const t=o,n=i.computed(()=>{const k=t.editor?.widget(t.wid)||t.widget||{};return k.btns||(k.btns=[]),k}),l=i.computed(()=>({visible:!0,name:"keywords",title:"关键字",placeholder:"请输入搜索内容",...n.value.keywords||{}})),s=i.computed(()=>{let k=[];return n.value.fields?.length&&(k=n.value.fields),k.length==0&&t.fields?.length&&(k=t.fields),k.sort((v,w)=>{const O=v.show?.query?.index||1,g=w.show?.query?.index||1;return O-g}),k.forEach(v=>{!v.widget&&!v.control&&v.convert&&(v.widget="unione-select-box"),v.widget=v.widget||v.control||"a-input",v.defaultValue!=null&&v.defaultValue!="undefined"&&typeof v.defaultValue<"u"&&(f.value[v.name]=v.defaultValue,v.value=v.defaultValue)}),k}),a=i.computed(()=>n.value.labelWidth||7),r=i.computed(()=>{const k=n.value.btns.filter(v=>v.name=="advanced")[0]||{};return k.event?.clickScript&&(k.event.click=new Function("ctx","btn","event",k.event.clickScript)),k.event?.disableScript&&(k.event.disable=new Function("ctx","btn",k.event.disableScript)),k.event?.visibleScript&&(k.event.visible=new Function("ctx","btn",k.event.visibleScript)),{visible:!0,name:"advanced",title:"高级搜索",...k}}),d=["query","reset","advanced"],h=i.computed(()=>{const k=n.value.btns.filter(w=>w.name!="advanced"),v=[];return k.forEach(w=>{w.size||(w.size="default"),v.push(w.name)}),v.includes("query")||k.splice(0,0,{visible:!0,name:"query",title:"查询",size:"default",type:"primary"}),v.includes("reset")||k.splice(1,0,{visible:!0,name:"reset",title:"重置",size:"default",type:"default"}),k.sort((w,O)=>{const g=w.index||1,p=O.index||1;return g-p}),k}),f=i.ref({}),c=i.computed(()=>{const k={};return n.value.params?Object.keys(n.value.params).forEach(v=>{k[v]=n.value.params[v]}):t.params&&Object.keys(t.params).forEach(v=>{k[v]=t.params[v]}),k});i.onMounted(()=>{t.editor?.ebus.$on("query-form-params",k=>{n.value.params=k}),b()});const u=e;function m({btn:k,event:v}){console.log("unione query form btn click",k,v),k.name=="query"&&b(),k.name=="reset"&&y(),u("btnClick",{btn:k,event:v})}function b(){const k=[];s.value.forEach(w=>{w.visible&&k.push(w.name)});const v={params:{...c.value},keywords:""};Object.keys(f.value).forEach(w=>{k.includes(w)&&(v.params[w]=f.value[w])}),l.value.visible&&f.value[l.value.name]&&(v.keywords=f.value[l.value.name]),u("query",v),t.editor?.ebus.$emit("table-list-search",v)}function y(){f.value={},s.value.forEach(v=>{v.visible=!1});const k={params:{...c.value},keywords:""};u("reset",k),t.editor?.ebus.$emit("table-list-reset",k)}return(k,v)=>{const w=i.resolveComponent("a-input"),O=i.resolveComponent("a-form-item"),g=i.resolveComponent("unione-btn"),p=i.resolveComponent("a-checkbox"),N=i.resolveComponent("DownOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("a-dropdown"),x=i.resolveComponent("a-form");return i.openBlock(),i.createBlock(ht,{class:"unione-query-form",model:t.editor?.model.value,"setting-title":"查询设置"},i.createSlots({default:i.withCtx(()=>[i.createVNode(x,{model:f.value,layout:"horizontal","label-col":{span:a.value}},{default:i.withCtx(()=>[l.value.visible?(i.openBlock(),i.createBlock(O,{key:0,label:l.value.title,class:"query-field keywords",name:l.value.name,style:i.normalizeStyle({width:a.value})},{default:i.withCtx(()=>[i.createVNode(w,{placeholder:l.value.placeholder,value:f.value[l.value.name],"onUpdate:value":v[0]||(v[0]=S=>f.value[l.value.name]=S),allowClear:"",onKeyup:i.withKeys(b,["enter"])},null,8,["placeholder","value"])]),_:1},8,["label","name","style"])):i.createCommentVNode("",!0),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,S=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:S.name},[S.visible?(i.openBlock(),i.createBlock(O,{key:0,label:S.title,class:i.normalizeClass(["query-field",S.name]),style:i.normalizeStyle({width:a.value}),name:S.name},{default:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(S.widget),i.mergeProps({placeholder:S.placeholder,value:f.value[S.name],"onUpdate:value":M=>f.value[S.name]=M,ref_for:!0},S.props||{},{allowClear:"",widget:S}),null,16,["placeholder","value","onUpdate:value","widget"]))]),_:2},1032,["label","class","style","name"])):i.createCommentVNode("",!0)],64))),128)),i.createElementVNode("div",sr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.value,S=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:S.name},[S.visible!=!1?(i.openBlock(),i.createBlock(g,{key:0,widget:S,editor:o.editor,onClick:m,preset:d},null,8,["widget","editor"])):i.createCommentVNode("",!0)],64))),128)),r.value.visible&&s.value.length?(i.openBlock(),i.createBlock(C,{key:0,class:"btn btn-advanced",trigger:[r.value.trigger||"hover"]},{overlay:i.withCtx(()=>[i.createElementVNode("div",or,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,S=>(i.openBlock(),i.createBlock(p,{key:S.name,class:"item",checked:S.visible,onClick:M=>S.visible=!S.visible},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(S.title),1)]),_:2},1032,["checked","onClick"]))),128))])]),default:i.withCtx(()=>[i.createVNode(V,null,{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value.title)+" ",1),i.createVNode(N)]),_:1})]),_:1},8,["trigger"])):i.createCommentVNode("",!0)])]),_:1},8,["model","label-col"])]),_:2},[t.editor&&t.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(lr,{editor:t.editor,wid:t.wid},null,8,["editor","wid"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-05f95e36"]]),ar={class:"unione-props-setting unione-table-setting"},rr={class:"unione-table-tools"},dr={key:1,class:"unione-table-opts"},cr={key:0},hr=["onClick"],fr={key:1,class:"edit-field"},ur=["onClick"],pr={key:1},mr=ne(i.defineComponent({__name:"tableSetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(o){const e=o,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:C})=>C+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"显示",dataIndex:"isList",key:"isList",width:"30px",align:"center"},{title:"排序",dataIndex:"isSort",key:"isSort",width:"30px",align:"center"},{title:"显示顺序",dataIndex:"showIndex",key:"showIndex",width:"55px",align:"center"},{title:"对齐方式",dataIndex:"align",key:"align",width:"55px",align:"center",options:[{value:"left",label:"居左"},{value:"center",label:"居中"},{value:"right",label:"居右"}],showLabel(C,x){let S=C.filter(M=>M.value==x);return S&&S[0]&&S[0].label||x}},{title:"固定位置",dataIndex:"fixed",key:"fixed",width:"55px",align:"center",options:[{value:"left",label:"靠左"},{value:"right",label:"靠右"}],showLabel(C,x){let S=C.filter(M=>M.value==x);return S&&S[0]&&S[0].label||x}},{title:"列宽",dataIndex:"showWidth",key:"showWidth",width:"50px",align:"center"}]),n=i.computed(()=>{const C=e.editor.widget(e.wid)||{};return C.configs||(C.configs={}),C.configs.leftBtns||(C.configs.leftBtns=[]),C.configs.rightBtns||(C.configs.rightBtns=[]),C.configs.operation||(C.configs.operation={}),C.configs.operation.btns||(C.configs.operation.btns=[]),C.configs.operation.more||(C.configs.operation.more={}),C}),l=i.computed(()=>(e.editor.dataModels()||[]).map(x=>({value:x.sn,label:x.title+"("+x.name+")"}))),s=i.computed(()=>{if(!n.value)return[];const C=[],x=n.value.configs.leftBtns;if(x.forEach(S=>{C.push(S.name)}),!C.includes("add")){const S={visible:!0,title:"新增",icon:"PlusOutlined",size:"small",index:0,type:"primary",props:{danger:!1,block:!1,ghost:!1},name:"add"};x.splice(0,0,S)}if(!C.includes("delBatch")){const S={visible:!0,title:"批量删除",icon:"DeleteOutlined",size:"small",index:1,type:"primary",props:{danger:!0,block:!1,ghost:!1},name:"delBatch"};x.splice(1,0,S)}return x}),a=i.computed(()=>{if(!n.value)return[];const C=[],x=n.value.configs.rightBtns;if(x.forEach(S=>{C.push(S.name)}),!C.includes("downData")){const S={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"导出",index:0,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downData"};x.splice(0,0,S)}if(!C.includes("impData")){const S={visible:!0,title:"导入",icon:"CloudUploadOutlined",size:"small",index:1,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"impData"};x.splice(1,0,S)}if(!C.includes("expData")){const S={visible:!0,title:"导出",icon:"CloudUploadOutlined",size:"small",index:2,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"expData"};x.splice(2,0,S)}if(!C.includes("downTmpl")){const S={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"模版",index:3,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downTmpl"};x.splice(3,0,S)}return x});function r(C,x){C=="left"?f.value.open(x,S=>{S.visible=!0,Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.leftBtns.sort((M,T)=>{const E=M.index||1,I=T.index||1;return E-I}),n.value.configs.leftBtns=[...n.value.configs.leftBtns]}):f.value.open(x,S=>{S.visible=!0,Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.rightBtns.sort((M,T)=>{const E=M.index||1,I=T.index||1;return E-I}),n.value.configs.rightBtns=[...n.value.configs.rightBtns]})}function d(C){const x=C=="left"?n.value.configs.leftBtns.length:n.value.configs.rightBtns.length;let S={title:"新增"+x,name:"new_"+x,index:x,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{}};C=="left"?n.value.configs.leftBtns.push(S):n.value.configs.rightBtns.push(S),e.editor.widget(e.wid,n.value),r(C,S)}function h(C,x){const S=()=>{if(["add","delBatch","expData","impData","downTmpl"].includes(x.name))x.visible=!1,C=="left"?n.value.configs.leftBtns=[...n.value.configs.leftBtns]:n.value.configs.rightBtns=[...n.value.configs.rightBtns];else if(C=="left"){const M=[];n.value.configs.leftBtns.forEach(T=>{T.name!=x.name&&M.push(T)}),n.value.configs.leftBtns=M}else{const M=[];n.value.configs.rightBtns.forEach(T=>{T.name!=x.name&&M.push(T)}),n.value.configs.rightBtns=M}};J.Modal.confirm({title:"确认信息",content:"请确定删除该工具?",onOk:()=>{S()}})}const f=i.ref(null);function c(C){f.value.open(C,x=>{x.visible=!0,Object.keys(x).forEach(S=>{C[S]=x[S]}),n.value.configs.operation.btns.sort((S,M)=>{const T=S.index||1,E=M.index||1;return T-E}),n.value.configs.operation.btns=[...n.value.configs.operation.btns]})}function u(){const C=n.value.configs.operation.btns.length+1;let x={title:"新增"+C,name:"new_"+C,index:C,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{clickScript:"",titleScript:"",disableScript:"",visibleScript:""}};n.value.configs.operation.btns.push(x),e.editor.widget(e.wid,n.value),f.value.open(x,S=>{Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.operation.btns=[...n.value.configs.operation.btns]})}function m(C){const x=()=>{if(["delete","view","edit"].includes(C.name))C.visible=!1,n.value.configs.operation.btns=[...n.value.configs.operation.btns];else{const S=[];n.value.configs.operation.btns.forEach(M=>{M.name!=C.name&&S.push(M)}),n.value.configs.operation.btns=S}};J.Modal.confirm({title:"确认信息",content:"请确定删除该操作?",onOk:()=>{x()}})}const b=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),y=i.computed(()=>b.value.fields?.length?(b.value.fields.forEach(C=>{C.show||(C.show={}),C.show.list||(C.show.list={})}),b.value.fields):[]),k={mounted:C=>C.focus()},v=i.ref({});function w(){const C=Object.keys(v.value);if(C.length)for(let x in C){const S=y.value.filter(M=>M.name==x);if(S&&S[0]){let M=v.value[x];Object.keys(M).forEach(T=>{S[0].show||(S[0].show={}),S[0].show.list||(S[0].show.list={}),T=="showIndex"?S[0].show.list.index=M[T]:T=="showWidth"?S[0].show.list.width=M[T]:T=="fixed"?S[0].show.list.fixed=M[T]:T=="align"?S[0].show.list.align=M[T]:S[0][T]=M[T]})}}v.value={}}function O(C,x){w();const S={};x=="showIndex"?S[x]=C.show?.list?.index:x=="showWidth"?S[x]=C.show?.list?.width:x=="fixed"?S[x]=C.show?.list?.fixed:x=="align"?S[x]=C.show?.list?.align:S[x]=C[x]||"",v.value[C.name]=S}function g(C,x){if(!C||!x){v.value={};return}const S=v.value[C.name][x];C.show||(C.show={}),C.show.list||(C.show.list={}),x=="showIndex"?C.show.list.index=S:x=="showWidth"?C.show.list.width=S:x=="fixed"?C.show.list.fixed=S:x=="align"?C.show.list.align=S:C[x]=S,v.value={}}function p(C,x){return x=="showIndex"?C.show?.list?.index:x=="showWidth"?C.show?.list?.width:x=="fixed"?C.show?.list?.fixed:x=="align"?C.show?.list?.align:C[x]}function N(C,x){y.value.filter(M=>M.name==C.name).forEach(M=>{M[x]=!M[x]})}const V=i.ref({options:[{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:C=>{const x=V.value.options.filter(S=>S.value==C);return x[0]?x[0].label:C}});return(C,x)=>{const S=i.resolveComponent("a-divider"),M=i.resolveComponent("CloseOutlined"),T=i.resolveComponent("a-button"),E=i.resolveComponent("PlusOutlined"),I=i.resolveComponent("a-input"),L=i.resolveComponent("a-form-item"),A=i.resolveComponent("a-col"),U=i.resolveComponent("a-input-number"),P=i.resolveComponent("a-checkbox"),G=i.resolveComponent("a-row"),j=i.resolveComponent("a-select"),B=i.resolveComponent("ToolOutlined"),F=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",ar,[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[8]||(x[8]=[i.createTextVNode("工具设置")])),_:1}),i.createElementVNode("div",rr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size,ref_for:!0},_.props||{},{onClick:D=>r("left",_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"bool-del",onClick:i.withModifiers(D=>h("left",_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","tool-add"]),size:"small",onClick:x[0]||(x[0]=_=>d("left"))},{default:i.withCtx(()=>[i.createVNode(E)]),_:1}),i.createVNode(T,{class:i.normalizeClass(["btn","tool-add","right"]),onClick:x[1]||(x[1]=_=>d("right")),size:"small"},{default:i.withCtx(()=>[i.createVNode(E)]),_:1}),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(a.value,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn","right",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size,ref_for:!0},_.props||{},{onClick:D=>r("right",_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"bool-del",onClick:i.withModifiers(D=>h("right",_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128))]),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[9]||(x[9]=[i.createTextVNode("操作设置")])),_:1}),n.value?.configs?.operation?(i.openBlock(),i.createBlock(G,{key:0},{default:i.withCtx(()=>[i.createVNode(A,{span:7},{default:i.withCtx(()=>[i.createVNode(L,{label:"操作标题"},{default:i.withCtx(()=>[i.createVNode(I,{value:n.value.configs.operation.title},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:5},{default:i.withCtx(()=>[i.createVNode(L,{label:"显示宽度",labelCol:{span:9}},{default:i.withCtx(()=>[i.createVNode(U,{value:n.value.configs.operation.width,"onUpdate:value":x[2]||(x[2]=_=>n.value.configs.operation.width=_)},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:6},{default:i.withCtx(()=>[i.createVNode(L,{label:"显示按钮数量",labelCol:{span:9}},{default:i.withCtx(()=>[i.createVNode(U,{value:n.value.configs.operation.count,"onUpdate:value":x[3]||(x[3]=_=>n.value.configs.operation.count=_)},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:5},{default:i.withCtx(()=>[i.createVNode(L,{label:"是否显示"},{default:i.withCtx(()=>[i.createVNode(P,{checked:n.value.configs.operation.visible,"onUpdate:checked":x[4]||(x[4]=_=>n.value.configs.operation.visible=_)},null,8,["checked"])]),_:1})]),_:1})]),_:1})):i.createCommentVNode("",!0),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[10]||(x[10]=[i.createTextVNode("操作按钮")])),_:1}),n.value?.configs?.operation?(i.openBlock(),i.createElementBlock("div",dr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.value.configs.operation.btns,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size||"small",ref_for:!0},_.props||{},{onClick:D=>c(_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"btn-del",onClick:i.withModifiers(D=>m(_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","btn-add"]),onClick:x[5]||(x[5]=_=>u()),size:"small"},{default:i.withCtx(()=>[i.createVNode(E)]),_:1})])):i.createCommentVNode("",!0),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[11]||(x[11]=[i.createTextVNode("表头设置")])),_:1}),x[12]||(x[12]=i.createTextVNode(" 数据模型:")),i.createVNode(j,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":x[6]||(x[6]=_=>n.value.dataModel=_)},null,8,["options","value"]),i.createVNode(F,{columns:t.value,"data-source":y.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:_})=>[["showIndex","showWidth","align","fixed"].includes(_.key)?(i.openBlock(),i.createElementBlock("span",cr,[i.createVNode(B),i.createTextVNode(" "+i.toDisplayString(_.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:_,record:D})=>[["showIndex","showWidth"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!v.value[D.name]||!Object.keys(v.value[D.name]).includes(_.dataIndex))&&!p(D,_.dataIndex)&&"empty"]),onClick:$=>O(D,_.dataIndex)},[v.value[D.name]&&Object.keys(v.value[D.name]).includes(_.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(U,{key:0,value:v.value[D.name][_.dataIndex],"onUpdate:value":$=>v.value[D.name][_.dataIndex]=$,onBlur:$=>g(D,_.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[k]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(p(D,_.dataIndex)),1)],64))],10,hr)):["isList","isQuery","isSort"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",fr,[i.createVNode(P,{checked:D[_.dataIndex],onClick:$=>N(D,_.dataIndex)},null,8,["checked","onClick"])])):["align","fixed"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!v.value[D.name]||!Object.keys(v.value[D.name]).includes(_.dataIndex))&&!p(D,_.dataIndex)&&"empty"]),onClick:$=>O(D,_.dataIndex)},[v.value[D.name]&&Object.keys(v.value[D.name]).includes(_.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(j,{key:0,value:D.show.list[_.dataIndex],"onUpdate:value":$=>D.show.list[_.dataIndex]=$,allowClear:!0,options:_.options,onBlur:x[7]||(x[7]=$=>g())},null,8,["value","onUpdate:value","options"])),[[k]]):(i.openBlock(),i.createElementBlock("span",pr,i.toDisplayString(_.showLabel(_.options,p(D,_.dataIndex))),1))],10,ur)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(ci,{ref_key:"btnSetting",ref:f,preset:["edit","view","add","delBatch","expData","impData","downTmpl"]},null,512)])}}}),[["__scopeId","data-v-c966c24c"]]);function nn(o){const e=o.toLowerCase().split("_"),t=[];t.push(e[0]);for(let n=1;n<e.length;n++){const l=e[n];l&&(t.push(l.charAt(0).toUpperCase()),l.length>1&&t.push(l.substring(1)))}return t.join("")}const gr={toHump:nn},kr={class:"unione-table-tools"},br={class:"unione-table-data"},yr={key:0,class:"unione-table-opts"},Cl=ne(i.defineComponent({__name:"tableList",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},loading:{type:Boolean,default:!1},pagination:{type:Object,required:!1},dataList:{type:Array,default(){return[]}},rowKey:{type:String,default:"id"}},emits:["edit","view","add","delete","delBatch","expData","impData","downTmpl","leftBtnClick","rightBtnClick","optBtnClick","btnClick","change"],setup(o,{expose:e,emit:t}){const n=Ie(),l=o,s=i.computed(()=>l.editor?.widget(l.wid)||l.widget||{}),a=i.computed(()=>s.value.props||{}),r=i.computed(()=>s.value.rowKey||l.rowKey||"id"),d=i.computed(()=>s.value.dsn?l.editor?.dataManager().use(s.value.dsn,"list"):null),h=i.computed(()=>{const E=l.dataList||[];return!E.length&&d.value?d.value.data().body||[]:E}),f=i.computed(()=>{if(s.value.operation==!1)return{visible:!1};const E=K.utils.obj.ext(s.value.operation||{},{title:"操作",width:200,count:2,btns:[],more:{title:"更多",visible:!0,trigger:"hover",size:"small",layout:"horizontal",items:[]}}),I=[];let L=(s.value.operation?.btns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A));if(L.forEach(A=>{I.push(A.name)}),I.includes("edit")||L.splice(0,0,{title:"编辑",name:"edit",type:"default",visible:!0}),I.includes("view")||L.splice(1,0,{title:"查看",name:"view",type:"default",visible:!0}),I.includes("delete")||L.push({title:"删除",name:"delete",type:"default",props:{danger:!0},visible:!0}),l.editor&&l.editor.type.value!="code"){const A=L.filter(P=>P.name=="edit")[0];if(A.visible&&(A.action||(A.action={}),A.action.type||(A.action.type="route"),!A.action.href)){const P=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form",G=l.editor.model.value;A.action.link=n.editPageUrl+"?psn="+P+"&model="+G+"&id={row."+l.rowKey+"}"}const U=L.filter(P=>P.name=="view")[0];if(U.visible&&(U.action||(U.action={}),U.action.type||(U.action.type="route"),!U.action.href)){const P=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form";U.action.link=n.viewPageUrl+"?psn="+P+"&model=view&id={row."+l.rowKey+"}"}}return L=L.filter(A=>A.visible!=!1).sort((A,U)=>{const P=A.index||1,G=U.index||1;return P-G}),E.count&&(L.length>E.count+1?(E.btns=L.slice(0,E.count),E.more.items=L.slice(E.count,L.length),E.more.visible=!0):(E.btns=L,E.more.visible=!1)),E}),c=i.computed(()=>{let E=[];s.value.columns?.length&&(E=[...s.value.columns]);const I=[];E.forEach((A,U)=>{A.dataIndex=A.name,A.convert&&(A.dataIndex=A.name+"Label",A.convertObj=new Ke(A.convert),A.customCell=(P,G,j)=>{const B=P[j.name];A.convertObj&&(P[j.dataIndex]==null||P[j.dataIndex]==null)&&B!=null&&B!=null&&(B+"").length>0&&(P[j.dataIndex]=B,A.convertObj.convert(B).then(F=>{F&&(P[j.dataIndex]=F)}))}),A.sort?.enable&&(A.sorter=!0,A.sort.multiple&&(A.sorter={},A.sorter.multiple=A.sort.multiple),A.sort.defoult&&(A.defaultSortOrder=A.sort.asc?"ascend":"descend")),A.customRender=({text:P})=>P||"--",A.fkey?.enable&&(A.fkey.labelName&&(A.dataIndex=nn(A.fkey.labelName)),A.fkey.labelTitle&&(A.title=A.fkey.labelTitle),A.customRender=({record:P,column:G})=>P&&P[G.name+"FEntry"]&&P[G.name+"FEntry"][G.dataIndex]||"--",A.fkey.fields?.forEach((P,G)=>{if(!P.name)return;const j=nn(P.name),B={fkName:A.name,title:P.title,name:j,dataIndex:P.name,width:P.width,index:P.index||U+G+1,customRender:({record:F,column:_})=>{if(F&&F[_.fkName+"FEntry"]){const D=F[_.fkName+"FEntry"][_.name];if(D)return P.convertObj&&P.convertObj.convert(D)||D}return"--"}};P.convert&&(P.convertObj=new Ke(P.convert)),I.push(B)}))}),I.forEach(A=>{E.splice(A.index,0,A)});const L=K.utils.obj.ext(s.value.rownum,{title:"序号",fixed:"left",align:"center",width:60,visible:!0});return L&&L.visible!=!1&&(L.customRender=A=>O.value?(O.value.current-1)*O.value.pageSize+A.index+1:A.index,E=[L,...E]),f.value&&f.value.visible!=!1&&E.push({fixed:"right",align:"center",...f.value,name:"operation"}),E}),u=i.computed(()=>{if(s.value.leftBtns===!1)return[];const E=[],I=[];if((s.value.leftBtns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A)).forEach(A=>{A.visible!=!1&&E.push(A),I.push(A.name),A.name=="delBatch"&&!g.value&&(A.visible=!1)}),!I.includes("add")){const A={visible:!0,title:"新增",icon:"PlusOutlined",size:"small",index:0,type:"primary",props:{danger:!1,block:!1,ghost:!1},name:"add"};E.splice(0,0,A)}if(!I.includes("delBatch")&&g.value){const A={visible:!0,title:"批量删除",icon:"DeleteOutlined",size:"small",index:1,type:"primary",props:{danger:!0,block:!1,ghost:!1},name:"delBatch"};E.splice(1,0,A)}if(l.editor&&l.editor.type.value!="code"){const A=E.filter(U=>U.name=="add")[0];if(A.visible&&(A.action||(A.action={}),A.action.type||(A.action.type="route"),!A.action.href)){const U=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form",P=l.editor.model.value;A.action.link=n.addPageUrl+"?psn="+U+"&model="+P}}return E});function m({btn:E,event:I}){if(n.isDebug&&console.log("unione table left btn click",E,I),E.name=="delBatch"){if(!p.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的记录!"});return}if(d.value){d.value.deleteByIds(p.value.selectedRowKeys).then(()=>{M(),S(!0)});return}J.Modal.confirm({title:"确认信息",content:"请确认是否要删除选中的("+p.value.selectedRowKeys.length+")数据",onOk:()=>{V("delBatch",{btn:E,event:I,keys:p.value.selectedRowKeys}),V("leftBtnClick",{btn:E,event:I,keys:p.value.selectedRowKeys}),V("btnClick",{btn:E,event:I,keys:p.value.selectedRowKeys})}});return}V(E.name,{btn:E,event:I}),V("leftBtnClick",{btn:E,event:I}),V("btnClick",{btn:E,event:I})}const b=i.computed(()=>{if(s.value.rightBtns===!1)return[];const E=[],I=[];if((s.value.rightBtns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A)).forEach(A=>{A.visible!=!1&&E.push(A),I.push(A.name)}),!I.includes("impData")){const A={visible:!0,title:"导入",icon:"CloudUploadOutlined",size:"small",index:1,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"impData"};E.splice(1,0,A)}if(!I.includes("expData")){const A={visible:!0,title:"导出",icon:"CloudUploadOutlined",size:"small",index:2,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"expData"};E.splice(2,0,A)}if(!I.includes("downTmpl")){const A={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"模版",index:3,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downTmpl"};E.splice(3,0,A)}return E});function y({btn:E,event:I}){n.isDebug&&console.log("unione table right btn click",E,I),V(E.name,{btn:E,event:I}),V("rightBtnClick",{btn:E,event:I}),V("btnClick",{btn:E,event:I})}const k=i.computed(()=>({bordered:!0,size:"small",...s.value.attrs||{}})),v=i.ref({}),w=i.ref(null),O=i.computed(()=>K.utils.obj.ext(l.pagination||s.value.pagination,{showTotal:E=>"共"+E+"记录",pageSize:l.pagination?.pageSize||d.value?.data()?.pageSize||10,current:l.pagination?.current||d.value?.data()?.page||1,total:l.pagination?.total||d.value?.data()?.total||0,position:["bottomCenter"]})),g=i.computed(()=>typeof s.value.selection<"u"?s.value.selection:!0),p=i.ref({selectedRowKeys:[],selectedRowList:[],onChange:(E,I)=>{p.value.selectedRowKeys=E,p.value.selectedRowList=I},getCheckboxProps:E=>({disabled:E.checkable})}),N=["edit","view","add","delete","delBatch","impData","expData","downTmpl"],V=t;function C({btn:E,event:I},L){if(n.isDebug&&console.log("unione table opt btn click",E,I),E.name=="delete"){if(d.value){d.value.deleteByIds([L[r.value]]).then(()=>{M(),p.value.selectedRowKeys=p.value.selectedRowKeys.filter(A=>A!=L[r.value]),p.value.selectedRowList=p.value.selectedRowList.filter(A=>A[r.value]!=L[r.value])});return}J.Modal.confirm({title:"确认信息",content:"请确认是否要删除该记录?",onOk:()=>{V(E.name,{btn:E,event:I,row:L}),V("optBtnClick",{btn:E,event:I,row:L}),V("btnClick",{btn:E,event:I,row:L})}});return}V(E.name,{btn:E,event:I,row:L}),V("optBtnClick",{btn:E,event:I,row:L}),V("btnClick",{btn:E,event:I,row:L})}function x(E,I,L,A){console.log("tableChanged",E,I,L,A),w.value={page:E.current,pageSize:E.pageSize},L&&(Array.isArray(L)?(w.value.sorts=[],L.forEach(U=>{w.value.sorts.push({name:U.column.name,asc:U.order=="ascend"})})):L.column&&(w.value.sorts=[{name:L.column.name,asc:L.order=="ascend"}])),M(),V("change",{pagination:E,filters:I,sorter:L,event:A})}function S(E=!1){E?(p.value.selectedRowKeys=[],p.value.selectedRowList=[]):J.Modal.confirm({title:"确认信息",content:`确定要清除当前选中的(${p.value.selectedRowKeys.length})条数据?`,centered:!0,onOk:()=>{p.value.selectedRowKeys=[],p.value.selectedRowList=[]}})}function M(){if(d.value){const E={page:O.value.current,pageSize:O.value.pageSize,keywords:v.value.keywords,body:v.value.params||{}};w.value?.page&&(E.page=w.value.page),w.value?.pageSize&&(E.pageSize=w.value.pageSize),w.value?.sorts&&(E.sorts=w.value.sorts),console.log("dataStorage find params",E),d.value.find(E)}}i.onMounted(()=>{c.value?.forEach(E=>{E.sort?.enable&&E.sort.defoult&&(w.value||(w.value={},w.value.sorts||(w.value.sorts=[]),w.value.sorts.push({name:E.name,asc:E.sort.asc==!0})))}),l.editor?.ebus.$on("table-list-search",E=>{console.log("table-list-search",E),v.value=E||{},M()}),l.editor?.ebus.$on("table-list-reset",()=>{console.log("table-list-reset"),v.value={},M(),S(!0)}),l.editor?.ebus.$on("table-list-reload",()=>{console.log("table-list-reload"),M()})});function T(){return{keys:p.value.selectedRowKeys,rows:p.value.selectedRowList}}return e({getSelected:T,clearSelected:S}),(E,I)=>{const L=i.resolveComponent("unione-btn"),A=i.resolveComponent("DownOutlined"),U=i.resolveComponent("a-button"),P=i.resolveComponent("a-dropdown"),G=i.resolveComponent("a-table");return i.openBlock(),i.createBlock(ht,{class:"unione-table-list",model:l.editor?.model.value,"setting-title":"列表设置"},i.createSlots({default:i.withCtx(()=>[i.createElementVNode("div",kr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(u.value,j=>(i.openBlock(),i.createBlock(L,{key:j.name,class:"btn",widget:j,editor:o.editor,onClick:m,preset:N,ctx:{sltKeys:p.value.selectedRowKeys,sltRows:p.value.selectedRowList}},null,8,["widget","editor","ctx"]))),128)),p.value.selectedRowKeys.length?(i.openBlock(),i.createElementBlock("span",{key:0,class:"selected-info",onClick:I[0]||(I[0]=j=>S())},"当前选中记录("+i.toDisplayString(p.value.selectedRowKeys.length)+")",1)):i.createCommentVNode("",!0),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(b.value,j=>(i.openBlock(),i.createBlock(L,{key:j.name,class:"btn right",widget:j,editor:o.editor,onClick:y,preset:N,ctx:{sltKeys:p.value.selectedRowKeys,sltRows:p.value.selectedRowList}},null,8,["widget","editor","ctx"]))),128))]),i.createElementVNode("div",br,[c.value&&c.value.length?(i.openBlock(),i.createBlock(G,i.mergeProps({key:0,columns:c.value,rowKey:r.value,"data-source":h.value,"row-selection":g.value?p.value:null,scroll:{x:a.value.scrollX||"max-content",y:a.value.scrollY},pagination:O.value,onChange:x},k.value),{bodyCell:i.withCtx(({column:j,record:B})=>[j.name==="operation"?(i.openBlock(),i.createElementBlock("div",yr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(f.value.btns,F=>(i.openBlock(),i.createBlock(L,{key:F.name,class:"opt",widget:F,editor:o.editor,onClick:_=>C(_,B),preset:N,ctx:{row:B}},null,8,["widget","editor","onClick","ctx"]))),128)),f.value.more?.visible!=!1&&f.value.more.items?.length?(i.openBlock(),i.createBlock(P,{key:0,trigger:[f.value.more.trigger||"hover"],class:i.normalizeClass(["opt-more",f.value.more.size||"small"])},{overlay:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["opt-more-overlay",f.value.more.layout])},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(f.value.more.items,F=>(i.openBlock(),i.createBlock(L,{key:F.name,class:"item",widget:F,editor:o.editor,onClick:_=>C(_,B),type:"text",preset:N,ctx:{row:B}},null,8,["widget","editor","onClick","ctx"]))),128))],2)]),default:i.withCtx(()=>[i.createVNode(U,null,{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(f.value.more.title)+" ",1),i.createVNode(A)]),_:1})]),_:2},1032,["trigger","class"])):i.createCommentVNode("",!0)])):i.createCommentVNode("",!0)]),_:1},16,["columns","rowKey","data-source","row-selection","scroll","pagination"])):i.createCommentVNode("",!0)])]),_:2},[l.editor&&l.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(mr,{editor:l.editor,wid:l.wid},null,8,["editor","wid"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-d11fa152"]]),wr={class:"page-setting-dialog"},jt=i.defineComponent({__name:"page",props:{settingTitle:{type:String,default:"页面设置"},editor:{type:Object,required:!1}},emits:["setting","saving"],setup(o,{emit:e}){const t=o,n=i.computed(()=>t.editor?.model?.value),l=K.useSession(),s=i.computed(()=>l.getPrincipal()),a=i.ref(!1);i.provide("closeSetting",()=>{t.editor?.save().then(u=>{a.value=!1})});function r(){a.value=!0}function d(){t.editor?.save().then(u=>{console.log("res",u)})}function h(){t.editor?.save().then(u=>{console.log("res",u)})}const f=i.ref("");function c(u){f.value||(f.value=n.value),u?t.editor?.setModel("edit"):t.editor?.setModel(f.value)}return(u,m)=>{const b=i.resolveComponent("SettingOutlined"),y=i.resolveComponent("a-tooltip"),k=i.resolveComponent("SaveOutlined"),v=i.resolveComponent("FormOutlined"),w=i.resolveComponent("StopOutlined"),O=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-page",n.value])},[n.value=="edit"&&u.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:0,title:o.settingTitle},{default:i.withCtx(()=>[i.createVNode(b,{class:"page-setting",onClick:r})]),_:1},8,["title"])):i.createCommentVNode("",!0),n.value=="edit"&&u.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:1,title:"保存页面"},{default:i.withCtx(()=>[i.createVNode(k,{class:"btn-save",onClick:d})]),_:1})):i.createCommentVNode("",!0),n.value!="edit"&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:2,title:"编辑页面"},{default:i.withCtx(()=>[i.createVNode(v,{class:"btn-edit",onClick:m[0]||(m[0]=g=>c(!0))})]),_:1})):i.createCommentVNode("",!0),n.value=="edit"&&u.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:3,title:"退出编辑"},{default:i.withCtx(()=>[i.createVNode(w,{class:"btn-edit",onClick:m[1]||(m[1]=g=>c(!1))})]),_:1})):i.createCommentVNode("",!0),i.renderSlot(u.$slots,"default"),n.value=="edit"?(i.openBlock(),i.createBlock(O,{key:4,title:t.settingTitle,open:a.value,"onUpdate:open":m[2]||(m[2]=g=>a.value=g),centered:"",width:"85%",onOk:h},{default:i.withCtx(()=>[i.createElementVNode("div",wr,[i.renderSlot(u.$slots,"page-setting")])]),_:3},8,["title","open"])):i.createCommentVNode("",!0)],2)}}}),xr={class:"unione-props-setting data-field-manage"},vr={key:0},Cr={key:1},Sr={key:2},Nr={key:3},Br={key:4},Or={key:5},Vr={key:6},_r=["onClick"],Mr=["onClick"],Tr=["onClick"],Ar={key:1},Er=ne(i.defineComponent({__name:"dataFieldMange",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:u})=>u+1},{title:"名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"标题",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"数据类型",dataIndex:"dataType",key:"dataType",width:"80px",align:"center"},{title:"长度",dataIndex:"dataLen",key:"dataLen",width:"60px",align:"center"},{title:"小数点",dataIndex:"dataPrec",key:"dataPrec",width:"60px",align:"center"},{title:"默认值",dataIndex:"defaultValue",key:"defaultValue",width:"60px",align:"center"},{title:"主键",dataIndex:"isPk",key:"isPk",width:"40px",align:"center"},{title:"外键",dataIndex:"isFk",key:"isFk",width:"30px",align:"center"},{title:"非空",dataIndex:"isNull",key:"isNull",width:"30px",align:"center"},{title:"同步",dataIndex:"syncDbEnable",key:"syncDbEnable",width:"30px",align:"center"},{title:"备注",dataIndex:"descs",key:"descs",width:"140px",align:"center"}]),t=i.useModel(o,"modelValue"),n=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:u=>{u.forEach(m=>{n.value.selectedRowKeys.includes(m)||n.value.selectedRowKeys.push(m);const b=[];t.value.forEach(y=>{!u.includes(y.name)&&n.value.selectedRowKeys.includes(y.name)&&b.push(y.name)}),b.length&&(n.value.selectedRowKeys=n.value.selectedRowKeys.filter(y=>!b.includes(y)))})}}),l={mounted:u=>u.focus()},s=i.ref({});function a(){const u=Object.keys(s.value);if(u.length)for(let m in u){const b=t.value.filter(y=>y.name==m);if(b&&b[0]){let y=s.value[m];Object.keys(y).forEach(k=>{b[0][k]=y[k]})}}s.value={}}function r(u,m){a();const b={};b[m]=u[m]||"",s.value[u.name]=b}function d(u,m){if(!u||!m){s.value={};return}const b=s.value[u.name][m];if(m=="name"&&t.value.filter(k=>k[m]==b&&k.name!=u.name).length>0){J.Modal.warn({title:"提示信息",content:"字段名称["+b+"]已存在"});return}u[m]=b,s.value={}}function h(u,m){t.value.filter(y=>y.name==u.name).forEach(y=>{y[m]=!y[m]})}function f(){if(a(),t.value.filter(b=>b.name=="new_").length>0){s.value.new_={name:"new_"};return}const m={title:"",name:"new_",isPk:!1};t.value.push(m),s.value[m.name]={name:"new_"}}function c(){if(!n.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的字段!"});return}J.Modal.confirm({title:"确认信息",content:"确定要删除选中的["+n.value.selectedRowKeys.length+"]字段么?",onOk:()=>{t.value=t.value.filter(u=>!n.value.selectedRowKeys.includes(u.name)),n.value.selectedRowKeys=[]}})}return(u,m)=>{const b=i.resolveComponent("a-button"),y=i.resolveComponent("a-tooltip"),k=i.resolveComponent("a-input"),v=i.resolveComponent("a-input-number"),w=i.resolveComponent("a-select-option"),O=i.resolveComponent("a-select"),g=i.resolveComponent("a-checkbox"),p=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",xr,[i.createVNode(b,{class:"btn btn-add",type:"primary",onClick:f,size:"small"},{default:i.withCtx(()=>m[1]||(m[1]=[i.createTextVNode("新增")])),_:1}),i.createVNode(b,{class:"btn btn-delete",type:"primary",danger:"",onClick:c,size:"small"},{default:i.withCtx(()=>m[2]||(m[2]=[i.createTextVNode(" 删除 ")])),_:1}),i.createVNode(p,{columns:e.value,"data-source":t.value,pagination:!1,bordered:"","row-selection":n.value,scroll:{x:1150},"row-key":"name",size:"small",sticky:""},{headerCell:i.withCtx(({column:N})=>[N.key==="name"?(i.openBlock(),i.createElementBlock("span",vr,[m[3]||(m[3]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="title"?(i.openBlock(),i.createElementBlock("span",Cr,[m[4]||(m[4]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="descs"?(i.openBlock(),i.createElementBlock("span",Sr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataLen"?(i.openBlock(),i.createElementBlock("span",Nr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataPrec"?(i.openBlock(),i.createElementBlock("span",Br,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="defaultValue"?(i.openBlock(),i.createElementBlock("span",Or,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataType"?(i.openBlock(),i.createElementBlock("span",Vr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="isPk"?(i.openBlock(),i.createBlock(y,{key:7,title:"至少配置一个主键字段"},{default:i.withCtx(()=>[m[5]||(m[5]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="isFk"?(i.openBlock(),i.createBlock(y,{key:8,title:"是否是外键字段"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="isNull"?(i.openBlock(),i.createBlock(y,{key:9,title:"是否允许为空"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="syncDbEnable"?(i.openBlock(),i.createBlock(y,{key:10,title:"是否同步到数据库"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:N,text:V,record:C})=>[["name","title","descs","defaultValue"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(k,{key:0,value:s.value[C.name][N.dataIndex],"onUpdate:value":x=>s.value[C.name][N.dataIndex]=x,onBlur:x=>d(C,N.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V||" "),1)],64))],10,_r)):i.createCommentVNode("",!0),["dataLen","dataPrec"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(v,{key:0,value:s.value[C.name][N.dataIndex],"onUpdate:value":x=>s.value[C.name][N.dataIndex]=x,onBlur:x=>d(C,N.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V||" "),1)],64))],10,Mr)):["dataType"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(O,{key:0,value:C[N.dataIndex],"onUpdate:value":x=>C[N.dataIndex]=x,onBlur:m[0]||(m[0]=x=>d())},{default:i.withCtx(()=>[i.createVNode(w,{key:"String",value:"String"}),i.createVNode(w,{key:"Long",value:"Long"}),i.createVNode(w,{key:"Short",value:"Short"}),i.createVNode(w,{key:"Integer",value:"Integer"}),i.createVNode(w,{key:"Float",value:"Float"}),i.createVNode(w,{key:"Double",value:"Double"}),i.createVNode(w,{key:"Date",value:"Date"}),i.createVNode(w,{key:"Timestamp",value:"Timestamp"})]),_:2},1032,["value","onUpdate:value"])),[[l]]):(i.openBlock(),i.createElementBlock("span",Ar,i.toDisplayString(V),1))],10,Tr)):["syncDbEnable","isFk","isPk"].includes(N.dataIndex)?(i.openBlock(),i.createBlock(g,{key:3,checked:C[N.dataIndex],onClick:x=>h(C,N.dataIndex)},null,8,["checked","onClick"])):["isNull"].includes(N.dataIndex)?(i.openBlock(),i.createBlock(g,{key:4,checked:!C[N.dataIndex],onClick:x=>h(C,N.dataIndex)},null,8,["checked","onClick"])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])])}}}),[["__scopeId","data-v-f6307a23"]]),Ir={class:"unione-props-setting data-field-setting"},Dr={key:0},Pr=["onClick"],Fr={class:"field-txt"},$r=["onClick"],Rr={key:1,class:"field-txt"},Lr=["onClick"],jr={key:1},zr=["onClick"],qr={key:0,class:"field-txt"},Ur={key:4,class:"edit-field"},Wr={key:0},Hr=["onClick"],Kr=ne(i.defineComponent({__name:"dataFieldSetting",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:v})=>v+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"isForm",key:"isForm",width:"40px",align:"center"},{title:"详情",dataIndex:"isView",key:"isView",width:"40px",align:"center"},{title:"列表",dataIndex:"isList",key:"isList",width:"40px",align:"center"},{title:"排序",dataIndex:"isSort",key:"isSort",width:"40px",align:"center"},{title:"查询",dataIndex:"isQuery",key:"isQuery",width:"40px",align:"center"},{title:"查询类型",dataIndex:"queryType",key:"queryType",width:"60px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),t=i.useModel(o,"modelValue"),n={mounted:v=>v.focus()},l=i.ref({});function s(){const v=Object.keys(l.value);if(v.length)for(let w in v){const O=t.value.filter(g=>g.name==w);if(O&&O[0]){let g=l.value[w];Object.keys(g).forEach(p=>{p=="convertName"?(O[0].convert||(O[0].convert={}),O[0].convert.type=g[p]):O[0][p]=g[p]})}}l.value={}}function a(v,w){s();const O={};w=="convertName"?(v.convert||(v.convert={}),O[w]=v.convert?.type):O[w]=v[w]||"",l.value[v.name]=O}function r(v,w){{l.value={};return}}function d(v,w){t.value.filter(g=>g.name==v.name).forEach(g=>{g[w]=!g[w]})}const h=i.ref({title:"列头设置",prop:"isList",visible:!1,field:{},show:{},toSetting:()=>{h.value.visible=!1}});function f(v,w){const O=t.value.filter(p=>p.name==v.name);O.forEach(p=>{w!="isSort"?p[w]=!0:p[w]=!p[w]});const g=O[0];if(!(!g||w=="isSort")){switch(h.value.prop=w,h.value.field=v,g.show||(g.show={}),w){case"isQuery":g.show.query||(g.show.query={}),h.value.show=g.show.query,h.value.title=`查询设置/${v.title}(${v.name})`;break;case"isForm":g.show.form||(g.show.form={}),h.value.show=g.show.form,h.value.title=`表单设置/${v.title}(${v.name})`;break;case"isView":g.show.view||(g.show.view={}),h.value.show=g.show.view,h.value.title=`详情设置/${v.title}(${v.name})`;break;case"isList":g.show.list||(g.show.list={}),h.value.show=g.show.list,h.value.title=`列头设置/${v.title}(${v.name})`;break}h.value.visible=!0}}const c=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:v=>{const w=c.value.options.filter(O=>O.value==v);return w[0]?w[0].label:v}}),u=i.ref({visible:!1,field:{},props:{},showInfo:v=>{let w="";return v.rules&&(w=v.rules.filter(O=>O.enable).length||""),w&&(w="("+w+")"),w},toSetting:()=>{const v=u.value.props,w={name:"range",trigger:v.trigger,whitespace:v.whitespace,message:v.rangeMessage};v.rangeMin!=null&&v.rangeMin!=null&&(w.min=v.rangeMin,w.enable=!0),v.rangeMax!=null&&v.rangeMax!=null&&(w.max=v.rangeMax,w.enable=!0);const O={name:"reg",trigger:v.trigger,whitespace:v.whitespace,message:v.regMessage};v.regExpress&&(O.pattern=v.regExpress,O.enable=!0),u.value.field.rules=[w,O],u.value.visible=!1,u.value.props={},console.log("rule",u.value.field.rules)}});function m(v){u.value.visible=!0,u.value.field=v;const w=v.rules||[],O={trigger:"change",whitespace:!0};w.forEach(g=>{g.name=="reg"&&(O.trigger=g.trigger,O.whitespace=g.whitespace,O.regExpress=g.pattern,O.regMessage=g.message),g.name=="range"&&(O.rangeMin=g.min,O.rangeMax=g.max,O.rangeMessage=g.message)}),u.value.props=O}const b=i.ref({visible:!1,field:{},props:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-textarea",label:"文本域"},{value:"a-input",label:"文本框"},{value:"a-checkbox",label:"多选框"},{value:"a-radio",label:"单选框"},{value:"a-input-number",label:"数值框"},{value:"a-select",label:"下拉框"},{value:"a-tree-select",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-switch",label:"开关"},{value:"a-slider",label:"滑块"}],widgetName:v=>{const w=b.value.widgets.filter(O=>O.value==v);return w[0]?w[0].label:v},toSetting:()=>{}}),y=i.ref({visible:!1,field:{},convert:{},optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],toAddOption:()=>{y.value.convert.options||(y.value.convert.options=[]),y.value.convert.options.push({label:"",value:""})},toDelOption:(v,w)=>{y.value.convert.options.splice(v,1)},toSetting:()=>{y.value.visible=!1}});function k(v){y.value.visible=!0,y.value.field=v,y.value.convert=v.convert||{}}return(v,w)=>{const O=i.resolveComponent("ToolOutlined"),g=i.resolveComponent("a-button"),p=i.resolveComponent("a-select"),N=i.resolveComponent("a-checkbox"),V=i.resolveComponent("a-table"),C=i.resolveComponent("a-input-number"),x=i.resolveComponent("a-form-item"),S=i.resolveComponent("a-input"),M=i.resolveComponent("a-form"),T=i.resolveComponent("a-modal"),E=i.resolveComponent("a-col"),I=i.resolveComponent("a-row"),L=i.resolveComponent("a-select-option"),A=i.resolveComponent("a-divider"),U=i.resolveComponent("a-checkbox-group");return i.openBlock(),i.createElementBlock("div",Ir,[i.createVNode(V,{columns:e.value,"data-source":t.value,bordered:"",scroll:{x:1e3},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:P})=>[["widget","queryType","rules","convertName"].includes(P.key)?(i.openBlock(),i.createElementBlock("span",Dr,[i.createVNode(O),i.createTextVNode(" "+i.toDisplayString(P.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:P,text:G,record:j})=>[["rules"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!u.value.showInfo(j)&&"empty"]),onClick:B=>m(j)},[i.createElementVNode("span",Fr,i.toDisplayString(u.value.showInfo(j)),1),u.value.showInfo(j)?(i.openBlock(),i.createBlock(g,{key:0,type:"link"},{default:i.withCtx(()=>w[22]||(w[22]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Pr)):["widget"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!G&&"empty"]),onClick:B=>a(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(p,{key:0,value:j[P.dataIndex],"onUpdate:value":B=>j[P.dataIndex]=B,allowClear:!0,options:b.value.widgets,onBlur:w[0]||(w[0]=B=>r())},null,8,["value","onUpdate:value","options"])),[[n]]):(i.openBlock(),i.createElementBlock("span",Rr,i.toDisplayString(b.value.widgetName(G)),1))],10,$r)):["queryType"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock(i.Fragment,{key:2},[j.isQuery?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!G&&"empty"]),onClick:B=>a(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(p,{key:0,value:j[P.dataIndex],"onUpdate:value":B=>j[P.dataIndex]=B,allowClear:!0,options:c.value.options,onBlur:w[1]||(w[1]=B=>r())},null,8,["value","onUpdate:value","options"])),[[n]]):(i.openBlock(),i.createElementBlock("span",jr,i.toDisplayString(c.value.showLabel(G)),1))],10,Lr)):i.createCommentVNode("",!0)],64)):["convertName"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:3,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!j.convert?.type&&"empty"]),onClick:B=>a(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(p,{key:0,value:j.convert.type,"onUpdate:value":B=>j.convert.type=B,options:[{value:"dict",label:"字典"},{value:"option",label:"静态"}],allowClear:!0,onBlur:w[2]||(w[2]=B=>r())},null,8,["value","onUpdate:value"])),[[n]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[j.convert?.type?(i.openBlock(),i.createElementBlock("span",qr,i.toDisplayString(j.convert.type=="dict"?"字典":"静态"),1)):i.createCommentVNode("",!0),j.convert?.type?(i.openBlock(),i.createBlock(g,{key:1,type:"link",onClick:i.withModifiers(B=>k(j),["stop"])},{default:i.withCtx(()=>w[23]||(w[23]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,zr)):["isQuery","isForm","isView","isList","isSort"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",Ur,[i.createVNode(N,{checked:j[P.dataIndex],onClick:B=>d(j,P.dataIndex)},null,8,["checked","onClick"]),i.createVNode(g,{type:"link",onClick:B=>f(j,P.dataIndex)},{default:i.withCtx(()=>w[24]||(w[24]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(T,{visible:h.value.visible,"onUpdate:visible":w[9]||(w[9]=P=>h.value.visible=P),title:h.value.title,onOk:h.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:h.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(x,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(C,{value:h.value.show.index,"onUpdate:value":w[3]||(w[3]=P=>h.value.show.index=P)},null,8,["value"])]),_:1}),["isQuery"].includes(h.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(x,{key:0,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.width,"onUpdate:value":w[4]||(w[4]=P=>h.value.show.width=P)},null,8,["value"])]),_:1})),["isForm","isView"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:1,label:"标题宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.labelWidth,"onUpdate:value":w[5]||(w[5]=P=>h.value.show.labelWidth=P)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isForm","isView"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:2,label:"控件宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.valueWidth,"onUpdate:value":w[6]||(w[6]=P=>h.value.show.valueWidth=P)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:3,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(p,{value:h.value.show.fixed,"onUpdate:value":w[7]||(w[7]=P=>h.value.show.fixed=P),options:[{value:"",label:"无"},{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:4,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(p,{value:h.value.show.align,"onUpdate:value":w[8]||(w[8]=P=>h.value.show.align=P),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(T,{visible:y.value.visible,"onUpdate:visible":w[11]||(w[11]=P=>y.value.visible=P),title:y.value.convert.type=="dict"?"字典设置":"选项设置",onOk:y.value.toSetting},{default:i.withCtx(()=>[y.value.convert.type!="dict"?(i.openBlock(),i.createElementBlock("div",Wr,[i.createVNode(g,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:y.value.toAddOption},{default:i.withCtx(()=>w[25]||(w[25]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(V,{columns:y.value.optionColumn,"data-source":y.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:P,text:G,record:j,index:B})=>[P.dataIndex==="label"?(i.openBlock(),i.createBlock(S,{key:0,value:j.label,"onUpdate:value":F=>j.label=F,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),P.dataIndex==="value"?(i.openBlock(),i.createBlock(S,{key:1,value:j.value,"onUpdate:value":F=>j.value=F,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),P.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:F=>y.value.toDelOption(B,j)},"删除",8,Hr)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])])):i.createCommentVNode("",!0),y.value.convert.type=="dict"?(i.openBlock(),i.createBlock(M,{key:1,model:y.value.convert,name:"basic","label-col":{span:8},"wrapper-col":{span:16},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(I,{type:"flex",style:{width:"100%"}},{default:i.withCtx(()=>[i.createVNode(E,{span:24,order:1},{default:i.withCtx(()=>[i.createVNode(x,{label:"字典名称:"},{default:i.withCtx(()=>[i.createVNode(S,{value:y.value.convert.dict,"onUpdate:value":w[10]||(w[10]=P=>y.value.convert.dict=P)},null,8,["value"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):i.createCommentVNode("",!0)]),_:1},8,["visible","title","onOk"]),i.createVNode(T,{visible:b.value.visible,"onUpdate:visible":w[13]||(w[13]=P=>b.value.visible=P),title:"控件设置",onOk:b.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:b.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[b.value.field.widget=="a-select"?(i.openBlock(),i.createBlock(x,{key:0,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(p,{value:b.value.props.mode,"onUpdate:value":w[12]||(w[12]=P=>b.value.props.mode=P),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(L,{value:"multiple"},{default:i.withCtx(()=>w[26]||(w[26]=[i.createTextVNode("多选")])),_:1}),i.createVNode(L,{value:"tags"},{default:i.withCtx(()=>w[27]||(w[27]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(T,{visible:u.value.visible,"onUpdate:visible":w[21]||(w[21]=P=>u.value.visible=P),title:"规则设置",onOk:u.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:u.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>w[28]||(w[28]=[i.createTextVNode("基本设置")])),_:1}),i.createVNode(x,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(U,{value:u.value.props.trigger,"onUpdate:value":w[14]||(w[14]=P=>u.value.props.trigger=P),options:["change","blur"]},null,8,["value"])]),_:1}),u.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(x,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(N,{value:u.value.props.whitespace,"onUpdate:value":w[15]||(w[15]=P=>u.value.props.whitespace=P),checked:u.value.props.whitespace},{default:i.withCtx(()=>w[29]||(w[29]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["value","checked"])]),_:1})),i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>w[30]||(w[30]=[i.createTextVNode("数值区间")])),_:1}),i.createVNode(x,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(C,{value:u.value.props.rangeMin,"onUpdate:value":w[16]||(w[16]=P=>u.value.props.rangeMin=P)},null,8,["value"]),w[31]||(w[31]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(C,{value:u.value.props.rangeMax,"onUpdate:value":w[17]||(w[17]=P=>u.value.props.rangeMax=P)},null,8,["value"])]),_:1}),i.createVNode(x,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(S,{value:u.value.props.rangeMessage,"onUpdate:value":w[18]||(w[18]=P=>u.value.props.rangeMessage=P)},null,8,["value"])]),_:1}),i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>w[32]||(w[32]=[i.createTextVNode("正则验证")])),_:1}),i.createVNode(x,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(S,{value:u.value.props.regExpress,"onUpdate:value":w[19]||(w[19]=P=>u.value.props.regExpress=P)},null,8,["value"])]),_:1}),i.createVNode(x,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(S,{value:u.value.props.regMessage,"onUpdate:value":w[20]||(w[20]=P=>u.value.props.regMessage=P)},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-ef9b9849"]]),Qr={class:"unione-props-setting data-field"},Gr=ne(i.defineComponent({__name:"dataField",props:i.mergeModels({filter:{type:Array,default(){return[]}}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const e=i.useModel(o,"modelValue");return(t,n)=>{const l=i.resolveComponent("OrderedListOutlined"),s=i.resolveComponent("a-tab-pane"),a=i.resolveComponent("ToolOutlined"),r=i.resolveComponent("a-tabs");return i.openBlock(),i.createElementBlock("div",Qr,[i.createVNode(r,null,{default:i.withCtx(()=>[i.createVNode(s,{key:"field-mange"},{tab:i.withCtx(()=>[i.createVNode(l),n[2]||(n[2]=i.createTextVNode("字段管理 "))]),default:i.withCtx(()=>[i.createVNode(Er,{modelValue:e.value,"onUpdate:modelValue":n[0]||(n[0]=d=>e.value=d)},null,8,["modelValue"])]),_:1}),i.createVNode(s,{key:"field-setting"},{tab:i.withCtx(()=>[i.createVNode(a),n[3]||(n[3]=i.createTextVNode("字段设置 "))]),default:i.withCtx(()=>[i.createVNode(Kr,{modelValue:e.value,"onUpdate:modelValue":n[1]||(n[1]=d=>e.value=d)},null,8,["modelValue"])]),_:1})]),_:1})])}}}),[["__scopeId","data-v-008d1148"]]),Yr={key:0,class:"data-model-list"},Xr=["onClick"],Jr=ne(i.defineComponent({__name:"dataDefine",props:{limit:{type:Number,default:100},editor:{type:Object,required:!0}},setup(o,{expose:e}){const t=i.computed(()=>l.editor.dataModels()),n=i.ref({sn:"new_",title:"新建数据",fields:[]});i.onMounted(()=>{t.value&&t.value[0]&&(n.value=t.value[0])});const l=o;function s(c){n.value=c}function a(){if(t.value.length>=l.limit){J.Modal.warn({title:"提示信息",content:"数据模型数量超出限制!"});return}const c=sa.v4(),u={sn:c,title:"新建数据",name:"new_",fields:[]};n.value=u,console.log("data model added",u),l.editor.dataModel(c,u)}const r={title:[{required:!0,message:"数据标题不能为空",trigger:"change"}],name:[{required:!0,message:"数据名称不能为空",trigger:"change"}],url:[{required:!0,message:"数据URl不能为空",trigger:"change"}]},d=i.ref(),h=i.inject("closeSetting");function f(){d.value.validate().then(c=>{h&&h()})}return e({toSaving:f}),(c,u)=>{const m=i.resolveComponent("a-input"),b=i.resolveComponent("a-form-item"),y=i.resolveComponent("a-textarea"),k=i.resolveComponent("a-form");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-props-setting","data-define",l.limit<=1&&"center"])},[l.limit>1?(i.openBlock(),i.createElementBlock("div",Yr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(t.value,v=>(i.openBlock(),i.createElementBlock("div",{key:v.sn,class:i.normalizeClass(["title",n.value&&n.value.sn==v.sn&&"slt"]),onClick:w=>s(v)},i.toDisplayString(v.title),11,Xr))),128)),i.createElementVNode("div",{class:"title btn-add",onClick:a},"+")])):i.createCommentVNode("",!0),i.createElementVNode("div",{class:i.normalizeClass(["data-model-form",l.limit<=1&&"center"])},[i.createVNode(k,{ref_key:"formObj",ref:d,rules:r,model:n.value,"label-col":{span:4},"wrapper-col":{span:20}},{default:i.withCtx(()=>[i.createVNode(b,{label:"数据标题",name:"title",required:""},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.title,"onUpdate:value":u[0]||(u[0]=v=>n.value.title=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据名称",name:"name",required:""},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.name,"onUpdate:value":u[1]||(u[1]=v=>n.value.name=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据URL",name:"url",required:"",tooltip:"数据请求url,统一使用post请求,保存接口:url/save,修改接口:url/update,查询接口:url/find,删除接口:url/delete,详情接口:url/detail"},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.url,"onUpdate:value":u[2]||(u[2]=v=>n.value.url=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据说明",name:"descs"},{default:i.withCtx(()=>[i.createVNode(y,{value:n.value.descs,"onUpdate:value":u[3]||(u[3]=v=>n.value.descs=v)},null,8,["value"])]),_:1})]),_:1},8,["model"]),i.createVNode(Gr,{modelValue:n.value.fields,"onUpdate:modelValue":u[4]||(u[4]=v=>n.value.fields=v)},null,8,["modelValue"])],2)],2)}}}),[["__scopeId","data-v-6be2cc50"]]),Zr={class:"unione-props-setting unione-page-setting"},zt=ne(i.defineComponent({__name:"pageSetting",props:{editor:{type:Object,required:!0}},setup(o){const e=o,t=i.ref({});return i.onMounted(()=>{t.value=e.editor.define.value}),(n,l)=>{const s=i.resolveComponent("a-form-item"),a=i.resolveComponent("a-input"),r=i.resolveComponent("a-switch"),d=i.resolveComponent("a-textarea"),h=i.resolveComponent("a-form"),f=i.resolveComponent("a-tab-pane"),c=i.resolveComponent("a-tabs");return i.openBlock(),i.createElementBlock("div",Zr,[i.createVNode(c,{type:"card"},{default:i.withCtx(()=>[i.createVNode(f,{key:"pageDefine",tab:"页面设置"},{default:i.withCtx(()=>[i.createVNode(h,{model:t.value,name:"basic","label-col":{span:5},"wrapper-col":{span:16},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[t.value.sn&&t.value.sn!="new_"?(i.openBlock(),i.createBlock(s,{key:0,label:"页面编码"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(t.value.sn)+"/V"+i.toDisplayString(t.value.vers),1)]),_:1})):i.createCommentVNode("",!0),i.createVNode(s,{label:"页面标题",required:""},{default:i.withCtx(()=>[i.createVNode(a,{value:t.value.title,"onUpdate:value":l[0]||(l[0]=u=>t.value.title=u)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"页面组件",required:""},{default:i.withCtx(()=>[i.createVNode(a,{value:t.value.component,"onUpdate:value":l[1]||(l[1]=u=>t.value.component=u)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"icon图标"},{default:i.withCtx(()=>[i.createVNode(a,{value:t.value.icon,"onUpdate:value":l[2]||(l[2]=u=>t.value.icon=u)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"是否全局"},{default:i.withCtx(()=>[i.createVNode(r,{checked:t.value.isGlobal,"onUpdate:checked":l[3]||(l[3]=u=>t.value.isGlobal=u),checkedValue:1,checkedChildren:"是",unCheckedChildren:"否",unCheckedValue:0},null,8,["checked"])]),_:1}),i.createVNode(s,{label:"是否模版"},{default:i.withCtx(()=>[i.createVNode(r,{checked:t.value.isTmpl,"onUpdate:checked":l[4]||(l[4]=u=>t.value.isTmpl=u),checkedValue:1,checkedChildren:"是",unCheckedChildren:"否",unCheckedValue:0},null,8,["checked"])]),_:1}),i.createVNode(s,{label:"页面备注"},{default:i.withCtx(()=>[i.createVNode(d,{value:t.value.descs,"onUpdate:value":l[5]||(l[5]=u=>t.value.descs=u),placeholder:"请输入页面备注...",rows:4},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1}),i.createVNode(f,{key:"dataDefine",tab:"数据设置"},{default:i.withCtx(()=>[i.createVNode(Jr,{editor:o.editor},null,8,["editor"])]),_:1})]),_:1})])}}}),[["__scopeId","data-v-2420ce7a"]]),Sl=ne(i.defineComponent({__name:"editor",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},pageDefine:{type:Object,required:!1}},setup(o){console.log("unione page view setup .....");const e=o,t={sn:"new_",title:"新建页面",types:"setting",vers:1,configs:{widgetList:[],dataModels:[]},component:"unione-page-view"},n=new ct,l=i.computed(()=>n.$widgetList.value||[]);i.watch(()=>e.pageDefine,a=>{a&&n.load(s.value,a)});const s=i.ref("new_");return i.onMounted(()=>{const a=i.inject("route");console.log("unione page view route",a),s.value=e.psn||a?.query?.psn||a?.meta?.psn||"new_",console.log("unione page view,psn:"+s.value),n.setModel("run"),n.load(s.value,e.pageDefine||t)}),(a,r)=>(i.openBlock(),i.createBlock(jt,{class:"unione-page-view","setting-title":"页面设置",editor:i.unref(n)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(l.value,d=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(d.render||d.widget),{key:d.wid,wid:d.wid,widget:d,editor:i.unref(n)},null,8,["wid","widget","editor"]))),128))]),_:2},[i.unref(n)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(n)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"]))}}),[["__scopeId","data-v-f792d0b4"]]),ed={class:"form-btns"},Nl=i.defineComponent({__name:"form",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},pageDefine:{type:Object,required:!1}},setup(o){const e=i.inject("router"),t=o,n={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[],dsnList:[]},component:"unione-page-view"},l=new ct,s=i.computed(()=>l.$widgetList.value||[]),a=i.computed(()=>{const c=l.define.value?.configs?.btns||[],u=c.map(m=>m.name);if(!u.includes("save")){const m={title:"保存",type:"primary",index:0,visible:!0,size:"default",name:"save"};c.splice(m.index,0,m)}if(!u.includes("submit")){const m={title:"提交",type:"primary",index:1,visible:!0,size:"default",name:"submit"};let b=m.index||1;c.splice(b,0,m)}if(!u.includes("reset")){const m={title:"重置",type:"default",index:2,visible:!0,size:"default",props:{danger:!0},name:"reset"};c.splice(m.index,0,m)}if(!u.includes("back")){const m={title:"返回",type:"default",index:3,visible:!0,size:"default",name:"back"};c.splice(m.index,0,m)}return l.model.value=="view"&&c.filter(m=>["save","submit","reset"].includes(m.name)).forEach(m=>{m.visible=!1}),c});function r({btn:c,event:u}){c.name=="save"&&d(),c.name=="reset",c.name=="back"&&h()}async function d(){const c=l.dataManager().form();let u={};for(let m in c){const b=await c[m].validate();if(l.dataManager().psn()==m){for(let y in u)b[y]=u[y];u=b}else u[m]=b}console.log("=======form data=====",u),l.dataManager().primary().save({data:u,params:l.dataManager().params}).then(m=>{console.log("save result:",m)})}function h(){e.back()}i.watch(()=>t.pageDefine,c=>{c&&l.load(f.value,c)});const f=i.ref("new_");return i.onMounted(()=>{const c=i.inject("route");console.log("unione page view route",c),f.value=t.psn||c?.query?.psn||c?.meta?.psn||"new_",console.log("unione page view,psn:"+f.value),l.setModel(c?.query?.model||c?.meta?.model||"run"),c?.query&&l.dataManager().params(c.query),l.load(f.value,t.pageDefine||n)}),(c,u)=>{const m=i.resolveComponent("unione-btn");return i.openBlock(),i.createBlock(jt,{class:"unione-page-form","setting-title":"页面设置",editor:i.unref(l)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,b=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(b.widget),{key:b.wid,wid:b.wid,widget:b,editor:i.unref(l)},null,8,["wid","widget","editor"]))),128)),i.createElementVNode("div",ed,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(a.value,b=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:b.name},[b.visible!=!1?(i.openBlock(),i.createBlock(m,{key:0,widget:b,editor:i.unref(l),ctx:{},onClick:r},null,8,["widget","editor"])):i.createCommentVNode("",!0)],64))),128))])]),_:2},[i.unref(l)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(l)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"])}}}),td=["onMouseover"],id={key:0,class:"node-opts"},nd={class:"form-warp"},ld={class:"form-btns"},Bl=i.defineComponent({__name:"tree",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},storage:{type:Object,required:!0},fields:{type:Array,required:!1},setting:{type:Object,required:!0},opts:{type:Object,required:!1},btns:{type:Object,required:!1},event:{type:Object,required:!1}},emits:["btnClick","treeClick"],setup(o,{emit:e}){const t=K.useDialog(),n=i.inject("router"),l=o,s={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[],dsnList:[]},component:"unione-page-tree"};function a(){if(l.fields?.length){const F={widget:"unione-form",dsn:"primary",primary:!0,widgets:l.fields};s.configs.widgets=[F]}s.configs.dsnList=["primary"],r.dataManager().use("primary","form").store(l.storage),s.configs.btns=l.btns||[],l.btns==!1&&(s.configs.btns=!1),s.configs.opts=l.opts||[],l.opts==!1&&(s.configs.opts=!1),s.configs.event=l.event||{},s.configs.setting=l.setting||{}}const r=new ct,d=i.ref(!1),h=i.ref([]),f=i.ref({}),c=i.ref(null),u=i.ref(null),m=i.ref([]),b=i.ref([]),y=i.ref(0),k=i.computed(()=>{const F={disabled:!1,draggable:!1,multiple:!1,selectable:!0,checkable:!1,showLine:!0,showIcon:!0,idField:"id",pidField:"pid",labelField:"title",leafField:"isLeaf",iconField:"iconName",...l.setting?.tree||{}};return r.define.value?.configs?.tree||F}),v=i.computed(()=>{const F=r.define.value?.configs?.opts;if(typeof F=="boolean"&&F==!1)return!1;const _=(F||[]).map($=>typeof $=="string"?{name:$,visible:!1}:$),D=[];return _.forEach($=>{D.push($.name)}),console.log("opts addBtn",_),_.filter($=>$.name=="add")[0]||{visible:!0,name:"add",icon:"PlusOutlined",title:"新建",props:{block:!0,type:"dashed"}}}),w=i.computed(()=>{const F=r.define.value?.configs?.opts;if(typeof F=="boolean"&&F==!1)return[];const _=(F||[]).map(Q=>typeof Q=="string"?{name:Q,visible:!1}:Q),D=[],$=[];return _.forEach(Q=>{$.push(Q.name),Q.name!="add"&&D.push(Q)}),$.includes("delete")||D.splice(1,0,{visible:!0,name:"delete",icon:"DeleteOutlined",tooltip:"删除",props:{type:"text"}}),$.includes("child")||D.splice(2,0,{visible:!0,name:"child",icon:"PlusOutlined",tooltip:"创建下级",props:{type:"text"}}),console.log("opts menuBtn",D),D});function O({btn:F,event:_},D){_.stopPropagation();const $=f.value[D[k.value.idField]];if(console.log("onTreeMenuClick,btn:",F),console.log("onTreeMenuClick,node:",D),console.log("onTreeMenuClick,curentNode:",$),F.name=="child"){const Q=f.value[$[k.value.idField]];Q.isLeaf=!1,c.value={},c.value[k.value.pidField]=Q[k.value.idField],c.value[k.value.labelField]="新建...",c.value[k.value.idField]="new_"+y.value,c.value.parentNode=Q,y.value=y.value+1,Q.children||(Q.children=[],b.value.push(Q[k.value.idField])),I.value.createNode&&I.value.createNode(c.value,Q,r.dataManager().params()),f.value[c.value[k.value.idField]]=c.value,Q.children.push(c.value),m.value=[c.value[k.value.idField]],r.dataManager().primary().setValue(c.value)}F.name=="delete"&&($[k.value.idField]&&($[k.value.idField]+"").startsWith("new_")?($.parentNode?$.parentNode.children=$.parentNode.children.filter(Q=>Q[k.value.idField]!=$[k.value.idField]):h.value=h.value.filter(Q=>Q[k.value.idField]!=$[k.value.idField]),delete f.value[$[k.value.idField]]):r.dataManager().primary().deleteByIds([$[k.value.idField]]).then(()=>{if($.parentNode){const Q=f.value[$[k.value.pidField]];Q.children=Q.children.filter(R=>R[k.value.idField]!=$[k.value.idField])}else h.value=h.value.filter(Q=>Q[k.value.idField]!=$[k.value.idField]);delete f.value[$[k.value.idField]]}))}function g(F,{expanded:_,node:D}){_&&(c.value=D.dataRef,r.dataManager().primary().setValue(c.value),T())}function p(F,_){_.selected?(c.value=_.node.dataRef,r.dataManager().primary().setValue(c.value)):c.value&&(m.value=[c.value[k.value.idField]]),U("treeClick",{keys:F,event:_})}const N=i.computed(()=>{if(l.storage?.orderBy){const F=l.storage.orderBy.split(" ");return[{name:F[0],asc:F[1].toLowerCase()=="asc"}]}return[]});i.watch(()=>l.params,()=>{d.value&&(h.value=[],f.value={},c.value=null,m.value=[],b.value=[],y.value=0,r.dataManager().params(l.params||{}),console.log("params changed props.params",l.params),T())}),i.watch(()=>c.value,()=>{console.log("active node changed",c.value),C(!c.value)});const V=i.ref(null);i.watch(V,()=>{V.value&&c.value&&r.dataManager().primary().setValue(c.value)});function C(F=!0){const _=r.dataManager().form();for(let D in _)_[D].setDisabled(F)}function x(){if(c.value={},c.value[k.value.pidField]=-1,c.value[k.value.labelField]="新建...",c.value[k.value.idField]="new_"+y.value,y.value=y.value+1,I.value.createNode&&I.value.createNode(c.value,null,r.dataManager().params()),c.value[k.value.pidField]==-1)h.value.push(c.value);else{const F=f.value[c.value[k.value.pidField]];F.children||(F.children=[]),F.children.push(c.value)}m.value=[c.value[k.value.idField]],f.value[c.value[k.value.idField]]=c.value,r.dataManager().primary().setValue(c.value)}const S=i.ref(""),M=tn(()=>{r.dataManager().primary().find({page:1,pageSize:9999,keywords:S.value,needCount:!1,body:k.value.async==!1?null:{},sorts:N.value}).then(F=>{if(f.value={},h.value=[],F.body?.length){const _={};F.body.forEach(D=>{_[D[k.value.idField]]=D}),F.body.forEach(D=>{const $=_[D[k.value.pidField]];$?($.children||($.children=[],$.isLeaf=!1),$.children.push(D)):h.value.push(D)})}})},400);function T(){const F={};if(F[k.value.pidField]=-1,c.value){if(c.value.children?.length||k.value.async==!1)return;F[k.value.pidField]=c.value[k.value.idField],r.dataManager().primary().find({page:1,pageSize:999,body:F,sorts:N.value}).then(_=>{c.value.children=_.body||[],c.value.children.forEach(D=>{D.isLeaf=!!D[k.value.leafField],f.value[D[k.value.idField]]=D,D.parentNode=f.value[D[k.value.pidField]]})})}else{const _=k.value.async==!1?null:{page:1,pageSize:999,body:F,sorts:N.value};r.dataManager().primary().find(_).then(D=>{if(k.value.async==!1){if(h.value=[],D.body?.length){const $={};D.body.forEach(Q=>{$[Q[k.value.idField]]=Q}),D.body.forEach(Q=>{const R=$[Q[k.value.pidField]];R?(R.children||(R.children=[],R.isLeaf=!1),R.children.push(Q)):h.value.push(Q)})}}else h.value=D.body||[],h.value.forEach($=>{$.isLeaf=!!$[k.value.leafField],f.value[$[k.value.idField]]=$})})}}const E=i.computed(()=>r.$widgetList.value||[]),I=i.computed(()=>{const F={...r.define.value?.configs?.event||{}};for(const _ in F)F[_]&&typeof F[_]!="function"&&F[_].enable&&F[_].scriptText&&(_=="createNode"?F[_]=new Function("node","parent","params",F[_].scriptText):F[_]=new Function("data","event",F[_].scriptText));return F}),L=i.computed(()=>r.define.value?.configs?.setting||l.setting||{});i.provide("pageSetting",L.value);const A=i.computed(()=>{const F=r.define.value?.configs?.btns;if(typeof F=="boolean"&&F==!1)return[];const _=(r.define.value?.configs?.btns||[]).map($=>typeof $=="string"?{name:$,visible:!1}:{size:"default",...$}),D=_.map($=>$.name);if(!D.includes("save")){const $={title:"保存",type:"primary",index:0,visible:!0,size:"default",name:"save"};_.splice($.index,0,$)}if(!D.includes("reset")){const $={title:"重置",type:"default",index:1,visible:!0,size:"default",props:{danger:!0},name:"reset"};_.splice($.index,0,$)}if(!D.includes("back")){const $={title:"返回",type:"default",index:_.length,visible:!0,size:"default",name:"back"};_.splice($.index,0,$)}return r.model.value=="view"&&_.filter($=>["save","submit","reset"].includes($.name)).forEach($=>{$.visible=!1}),_}),U=e;function P({btn:F,event:_}){F.name=="save"&&G({btn:F,event:_}),F.name=="reset",F.name=="back"&&j(),U("btnClick",{btn:F,event:_})}async function G(F){const _=r.dataManager().form();let D={...c.value};for(let $ in _){const Q=await _[$].validate();if(r.dataManager().psn()==$)for(let R in Q)D[R]=Q[R];else D[$]=Q}if(D[k.value.pidField]&&(D[k.value.pidField]+"").startsWith("new_")){t.error({content:"请先保存父节点!"});return}D[k.value.idField]&&(D[k.value.idField]+"").startsWith("new_")&&delete D[k.value.idField],delete D.parentNode,delete D.children,D[k.value.leafField]=D[k.value.leafField]?1:0,I.value.preSave&&I.value.preSave(D,F),console.log("=======form data=====",D),r.dataManager().primary().save({data:D}).then($=>{console.log("save result:",$),c.value[k.value.idField]=$.body,m.value=[$.body],f.value[$.body]=c.value,c.value.children?.forEach(Q=>{Q[k.value.pidField]=$.body}),I.value.postSaved&&I.value.postSaved(D,F)})}function j(){n.back()}const B=i.ref("new_");return i.onMounted(()=>{const F=i.inject("route");console.log("unione page tree route",F),B.value=l.psn||F?.query?.psn||F?.meta?.psn||"new_",console.log("unione page tree,psn:"+B.value),r.setModel(F?.query?.model||F?.meta?.model||"run");const _={...l.params||{},...F?.query||{},...F?.params||{}};r.dataManager().params(_),a(),r.load(B.value,s),i.nextTick(()=>{C(!0)}),T(),d.value=!0}),(F,_)=>{const D=i.resolveComponent("SearchOutlined"),$=i.resolveComponent("a-input"),Q=i.resolveComponent("unione-btn"),R=i.resolveComponent("a-tree");return i.openBlock(),i.createBlock(jt,{class:"unione-page-tree","setting-title":"页面设置",editor:i.unref(r)},i.createSlots({default:i.withCtx(()=>[i.createElementVNode("div",{class:"tree-warp",onContextmenu:_[4]||(_[4]=i.withModifiers(()=>{},["prevent"]))},[i.createVNode($,{size:"small",class:"input-search",placeholder:"输入关键字搜索...",value:S.value,"onUpdate:value":_[0]||(_[0]=X=>S.value=X),onChange:i.unref(M),onPressEnter:i.unref(M)},{suffix:i.withCtx(()=>[i.createVNode(D)]),_:1},8,["value","onChange","onPressEnter"]),v.value?(i.openBlock(),i.createBlock(Q,{key:0,widget:v.value,onClick:x},null,8,["widget"])):i.createCommentVNode("",!0),i.createVNode(R,{"show-line":k.value.showLine,"show-icon":k.value.showIcon,disabled:k.value.disabled,blockNode:!0,draggable:k.value.draggable,multiple:k.value.multiple,selectable:k.value.selectable,checkable:k.value.checkable,fieldNames:{title:k.value.labelField,key:k.value.idField},selectedKeys:m.value,"onUpdate:selectedKeys":_[2]||(_[2]=X=>m.value=X),expandedKeys:b.value,"onUpdate:expandedKeys":_[3]||(_[3]=X=>b.value=X),"tree-data":h.value,onExpand:g,onSelect:p},i.createSlots({icon:i.withCtx(({dataRef:X})=>[X[k.value.iconField]?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(X[k.value.iconField]),{key:0})):i.createCommentVNode("",!0)]),_:2},[w.value?.length?{name:"title",fn:i.withCtx(({dataRef:X})=>[i.createElementVNode("div",{class:"node-label",onMouseover:()=>u.value=X,onMouseleave:_[1]||(_[1]=()=>u.value=null)},[i.createElementVNode("span",null,i.toDisplayString(X[k.value.labelField]),1),c.value&&c.value[k.value.idField]==X[k.value.idField]||u.value&&u.value[k.value.idField]==X[k.value.idField]?(i.openBlock(),i.createElementBlock("div",id,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(w.value,Z=>(i.openBlock(),i.createElementBlock(i.Fragment,null,[!I.value.btnVisible||I.value.btnVisible(Z,X)?(i.openBlock(),i.createBlock(Q,{key:Z.name,widget:Z,ctx:{node:X},onClick:ge=>O(ge,X)},null,8,["widget","ctx","onClick"])):i.createCommentVNode("",!0)],64))),256))])):i.createCommentVNode("",!0)],40,td)]),key:"0"}:void 0]),1032,["show-line","show-icon","disabled","draggable","multiple","selectable","checkable","fieldNames","selectedKeys","expandedKeys","tree-data"])],32),i.createElementVNode("div",nd,[i.renderSlot(F.$slots,"form-warp",{class:"form-warp"},()=>[i.createElementVNode("div",{ref_key:"formWarp",ref:V},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(E.value,X=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(X.widget),{key:X.wid,wid:X.wid,widget:X,editor:i.unref(r)},null,8,["wid","widget","editor"]))),128)),i.createElementVNode("div",ld,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(A.value,X=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:X.name},[X.visible!=!1?(i.openBlock(),i.createBlock(Q,{key:0,widget:X,editor:i.unref(r),disabled:!c.value,ctx:{},onClick:P},null,8,["widget","editor","disabled"])):i.createCommentVNode("",!0)],64))),128))])],512)])])]),_:2},[i.unref(r)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(r)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"])}}}),Ol=i.defineComponent({__name:"list",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},storage:{type:Object,required:!0},fields:{type:Array,required:!0},queryBtns:{type:Array,required:!1},operation:{type:Object,required:!1},selection:{type:Object,required:!1},leftBtns:{type:Object,required:!1},rightBtns:{type:Object,required:!1}},emits:["btnClick"],setup(o,{expose:e,emit:t}){const n=o,l=i.ref(null),s={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[{widget:"unione-query",dsn:"",primary:!0,fields:[]},{widget:"unione-table",dsn:"",columns:[]}],dsnList:[]},component:"unione-page-list"};function a(){if(n.fields?.length){s.configs.widgets[0].dsn="primary",s.configs.widgets[0].fields=n.fields.filter(O=>O.isQuery),s.configs.widgets[0].btns=n.queryBtns||[],s.configs.widgets[0].params=n.params||{},s.configs.dsnList=["primary"],s.configs.widgets[1].dsn="primary";const w=n.fields.filter(O=>O.isPk)[0];w&&w.name&&(s.configs.widgets[1].dataKey=w.name),s.configs.widgets[1].columns=n.fields.filter(O=>O.hidden!=!0),s.configs.widgets[1].operation=K.utils.obj.ext(s.configs.widgets[1].operation,n.operation||{}),n.operation==!1&&(s.configs.widgets[1].operation=!1),n.selection==!1&&(s.configs.widgets[1].selection=!1),s.configs.widgets[1].leftBtns=n.leftBtns==!1?!1:n.leftBtns||[],s.configs.widgets[1].rightBtns=n.rightBtns==!1?!1:n.rightBtns||[],r.dataManager().use("primary","list").store(n.storage)}}const r=new ct,d=i.computed(()=>r.$widgetList.value||[]),h=t;function f(w){h("btnClick",w)}const c=i.ref("new_");i.onMounted(()=>{const w=i.inject("route");console.log("unione page view route",w),c.value=n.psn||w?.query?.psn||w?.meta?.psn||"new_",console.log("unione page view,psn:"+c.value),r.setModel(w?.query?.model||w?.meta?.model||"run");const O={...n.params||{},...w?.query||{},...w?.params||{}};r.dataManager().params(O),a(),r.load(c.value,s)});function u(){return r.dataManager().use("primary","list")}function m(w){w?r.ebus.$emit("table-list-search",w):r.ebus.$emit("table-list-reload")}function b(w){r.dataManager().params(w),r.ebus.$emit("query-form-params",w),r.ebus.$emit("table-list-search",{params:w})}function y(){return l.value?l.value[0]:null}function k(){return l.value?l.value[0].getSelected():null}function v(){l.value&&l.value[0].clearSelected()}return e({storage:u,editor:r,reload:m,setParams:b,getTable:y,getSelected:k,clearSelected:v}),(w,O)=>(i.openBlock(),i.createBlock(jt,{class:"unione-page-list","setting-title":"页面设置",editor:i.unref(r)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(d.value,g=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:g.wid},[g.widget=="unione-table"?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(g.widget),{key:0,wid:g.wid,widget:g,editor:i.unref(r),onBtnClick:f,ref_for:!0,ref_key:"table",ref:l},null,40,["wid","widget","editor"])):(i.openBlock(),i.createBlock(i.resolveDynamicComponent(g.widget),{key:1,wid:g.wid,widget:g,editor:i.unref(r),onBtnClick:f},null,40,["wid","widget","editor"]))],64))),128))]),_:2},[i.unref(r)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(r)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"]))}}),ft={release(o){return K.axios.admin({url:"/api/data/define/release",method:"post",data:o})},find(o){return K.axios.admin({url:"/api/data/define/find",method:"post",data:o})},save(o){return K.axios.admin({url:"/api/data/define/save",method:"post",data:o})},delete(o){return K.axios.admin({url:"/api/data/define/delete",method:"post",data:o})},detail(o){return K.axios.admin({url:"/api/data/define/detail",method:"post",headers:{"Content-Type":"application/json"},data:o})},loadFromDb(o){return K.axios.admin({url:"/api/data/define/load/from/db",method:"post",headers:{"Content-Type":"multipart/form-data"},data:o})},impFromDb(o){return K.axios.admin({url:"/api/data/define/imp/from/db",method:"post",headers:{"Content-Type":"multipart/form-data"},data:o})}},sd={class:"unione-page list-page"},od=ne(i.defineComponent({__name:"list",setup(o){const e=Ie(),t=K.useDialog(),n=i.inject("router"),l=i.ref({fields:[{title:"标题",name:"title"},{title:"名称",name:"name"},{title:"状态",name:"status"},{title:"类别",name:"category"}]}),s=i.ref({leftBtns:[{visible:!1,name:"delBatch"},{title:"从数据库导入",icon:"FunnelPlotOutlined",name:"impFromDb",props:{danger:!0,ghost:!0}},{title:"代码生成",icon:"CodeOutlined",name:"genCode"}],rightBtns:[{visible:!1,name:"downTmpl"}],columns:[{title:"类别",name:"category"},{title:"标题",name:"title"},{title:"名称",name:"name"},{title:"编码",name:"sn"},{title:"版本",name:"vers"},{title:"发布时间",name:"publishDate"},{title:"创建时间",name:"created"},{title:"状态",name:"status"}],operation:{title:"操作",width:190,btns:[{title:"预览",name:"view"},{title:"版本发布",name:"release",props:{danger:!0}},{title:"版本管理",name:"vers"},{title:"配置管理",name:"configs"},{title:"权限管理",name:"permis"},{title:"权限分配",name:"auth"},{title:"复制",name:"copy"}],count:2,more:{layout:"vertical"}}});i.onMounted(()=>{r()});const a=i.ref({pagination:{total:0,current:1,pageSize:20},loading:!1,params:{},data:[]});function r(){a.value.loading=!0,ft.find({page:a.value.pagination.current,pageSize:a.value.pagination.pageSize,body:a.value.params,keywords:a.value.keywords}).then(g=>{a.value.data=g.body,a.value.pagination.total=g.total*1}).finally(()=>{a.value.loading=!1})}function d(g){a.value.pagination.current=g.pagination.current,a.value.pagination.pageSize=g.pagination.pageSize,r()}function h({params:g,keywords:p}){a.value.pagination.current=1,a.value.params=g,a.value.keywords=p,r()}function f({btn:g,event:p,row:N}){console.log("table btn click",g,p,N),(g.name=="add"||g.name=="edit")&&n.push({path:"/system/data/define/edit",query:N?{id:N.id}:{}}),g.name=="impFromDb"&&(u.value=!0),g.name=="release"&&c(N),g.name=="view"&&n.push({path:e.listPageUrl,query:{psn:N.sn+":list",model:"preview"}})}function c(g){t.confirm({content:"确定要发布当前数据么?",onOk:()=>{ft.release([g.id]).then(p=>{p.success?(t.success({title:"发布成功",content:p.body}),r()):t.error({title:"发布失败",content:p.body})})}})}const u=i.ref(!1),m=i.ref({keywords:{visible:!1},fields:[{title:"数据源",name:"dsId",value:1,visible:!0,widget:"unione-select-box",convert:{types:"local",url:"/api/data/source/find",search:!0}},{title:"名称",name:"tableName",visible:!0}],btns:[{visible:!1,name:"reset"},{name:"advanced",visible:!1},{name:"imp",title:"提交",props:{danger:!0}}]}),b=i.ref({leftBtns:!1,rightBtns:!1,columns:[{title:"名称",name:"name"},{title:"标题",name:"title"}],operation:!1}),y=i.ref({pagination:{total:0,current:1,pageSize:10},loading:!1,params:{},data:[]});function k(g){!g||!Object.keys(g).length||!g.dsId||(J.message.loading("数据加载中..."),y.value.params=g,y.value.loading=!0,ft.loadFromDb(g).then(p=>{y.value.loading=!1,J.message.destroy(),p.success?(p.body.forEach(N=>{N.checkable=!!N.id}),y.value.data=p.body,y.value.pagination.total=p.body.length):J.message.error(p.message)}))}function v(g){y.value.pagination.current=g.pagination.current,y.value.pagination.pageSize=g.pagination.pageSize}const w=i.ref();function O({btn:g}){if(g.name!="imp")return;const p=w.value.getSelected();p?.keys?.length?t.confirm({content:"确定导入选中的"+p.keys.length+"条记录么?",onOk:()=>{J.message.loading("数据导入中..."),ft.impFromDb({dsId:y.value.params.dsId,tables:p.keys.join()}).then(N=>{J.message.destroy(),N.success?(t.success({content:N.message}),a.value.pagination.current=1,r()):t.error({context:N.message})})}}):t.error({content:"请选择目标记录!"})}return(g,p)=>{const N=i.resolveComponent("UnioneQuery"),V=i.resolveComponent("UnioneTable"),C=i.resolveComponent("a-drawer");return i.openBlock(),i.createElementBlock("div",sd,[i.createVNode(N,{widget:l.value,onQuery:h,onReset:h},null,8,["widget"]),i.createVNode(V,{widget:s.value,dataList:a.value.data,loading:a.value.loading,pagination:a.value.pagination,onChange:d,onBtnClick:f},null,8,["widget","dataList","loading","pagination"]),i.createVNode(C,{title:"从数据库中导入",width:550,visible:u.value,"onUpdate:visible":p[0]||(p[0]=x=>u.value=x),placement:"left"},{default:i.withCtx(()=>[i.createVNode(N,{widget:m.value,onQuery:k,onReset:k,onBtnClick:O,class:"load-table-form"},null,8,["widget"]),i.createVNode(V,{widget:b.value,dataList:y.value.data,loading:y.value.loading,pagination:y.value.pagination,onChange:v,rowKey:"name",ref_key:"loadTableObj",ref:w},null,8,["widget","dataList","loading","pagination"])]),_:1},8,["visible"])])}}}),[["__scopeId","data-v-483acb94"]]),ad={class:"unione-props-setting data-field-manage"},rd={key:0},dd={key:1},cd=["onClick"],hd=["onClick"],fd=["onClick"],ud={key:1},pd=ne(i.defineComponent({__name:"dataFieldMange",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:m})=>m+1},{title:"名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"标题",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"数据类型",dataIndex:"dataType",key:"dataType",width:"80px",align:"center"},{title:"长度",dataIndex:"dataLen",key:"dataLen",width:"60px",align:"center"},{title:"小数点",dataIndex:"dataPrec",key:"dataPrec",width:"60px",align:"center"},{title:"默认值",dataIndex:"dataValue",key:"dataValue",width:"60px",align:"center"},{title:"主键",dataIndex:"isPk",key:"isPk",width:"40px",align:"center"},{title:"外键",dataIndex:"isFk",key:"isFk",width:"30px",align:"center"},{title:"非空",dataIndex:"isNull",key:"isNull",width:"30px",align:"center"},{title:"同步",dataIndex:"syncEnable",key:"syncEnable",width:"30px",align:"center"},{title:"备注",dataIndex:"descs",key:"descs",width:"140px",align:"center"}]),t=i.useModel(o,"modelValue"),n=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:m=>{m.forEach(b=>{n.value.selectedRowKeys.includes(b)||n.value.selectedRowKeys.push(b);const y=[];t.value.forEach(k=>{!m.includes(k.name)&&n.value.selectedRowKeys.includes(k.name)&&y.push(k.name)}),y.length&&(n.value.selectedRowKeys=n.value.selectedRowKeys.filter(k=>!y.includes(k)))})}}),l={mounted:m=>m.focus()},s=i.ref({});function a(){const m=Object.keys(s.value);if(m.length)for(let b in m){const y=t.value.filter(k=>k.name==b);if(y&&y[0]){let k=s.value[b];Object.keys(k).forEach(v=>{y[0][v]=k[v]})}}s.value={}}function r(m,b){a();const y={};y[b]=m[b]||"",s.value[m.name]=y}function d(m,b){if(!m||!b){s.value={};return}const y=s.value[m.name][b];if(b=="name"&&t.value.filter(v=>v[b]==y&&v.name!=m.name).length>0){J.Modal.warn({title:"提示信息",content:"字段名称["+y+"]已存在"});return}m[b]=y,s.value={}}function h(m,b){const y=t.value.filter(k=>k.name==m.name)[0];return b=="isFk"?y.configs?.fkey?.enable:y[b]==1}function f(m,b){const y=t.value.filter(k=>k.name==m.name)[0];b=="isFk"?(y.configs||(y.configs={}),y.configs.fkey||(y.configs.fkey={}),y.configs.fkey.enable=!y.configs.fkey.enable):y[b]!=1?y[b]=1:y[b]=0}function c(){if(a(),t.value.filter(y=>y.name=="new_").length>0){s.value.new_={name:"new_"};return}const b={title:"",name:"new_",dataType:"String",isPk:0};t.value.push(b),s.value[b.name]={name:"new_"}}function u(){if(!n.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的字段!"});return}J.Modal.confirm({title:"确认信息",content:"确定要删除选中的["+n.value.selectedRowKeys.length+"]字段么?",onOk:()=>{t.value=t.value.filter(m=>!n.value.selectedRowKeys.includes(m.name)),n.value.selectedRowKeys=[]}})}return(m,b)=>{const y=i.resolveComponent("a-button"),k=i.resolveComponent("a-tooltip"),v=i.resolveComponent("a-input"),w=i.resolveComponent("a-input-number"),O=i.resolveComponent("a-select-option"),g=i.resolveComponent("a-select"),p=i.resolveComponent("a-checkbox"),N=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",ad,[i.createVNode(y,{class:"btn btn-add",type:"primary",onClick:c,size:"small"},{default:i.withCtx(()=>b[1]||(b[1]=[i.createTextVNode("新增")])),_:1}),i.createVNode(y,{class:"btn btn-delete",type:"primary",danger:"",onClick:u,size:"small"},{default:i.withCtx(()=>b[2]||(b[2]=[i.createTextVNode(" 删除 ")])),_:1}),i.createVNode(N,{columns:e.value,"data-source":t.value,pagination:!0,bordered:"","row-selection":n.value,scroll:{x:1150},"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:V})=>[["name","title"].includes(V.key)?(i.openBlock(),i.createElementBlock("span",rd,[b[3]||(b[3]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(V.title),1)])):i.createCommentVNode("",!0),["descs","dataLen","dataPrec","dataValue","dataType"].includes(V.key)?(i.openBlock(),i.createElementBlock("span",dd,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(V.title),1)])):i.createCommentVNode("",!0),V.key==="isPk"?(i.openBlock(),i.createBlock(k,{key:2,title:"至少配置一个主键字段"},{default:i.withCtx(()=>[b[4]||(b[4]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="isFk"?(i.openBlock(),i.createBlock(k,{key:3,title:"是否是外键字段"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="isNull"?(i.openBlock(),i.createBlock(k,{key:4,title:"是否允许为空"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="syncEnable"?(i.openBlock(),i.createBlock(k,{key:5,title:"是否同步到数据库"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:V,text:C,record:x})=>[["name","title","descs","dataValue"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(v,{key:0,value:s.value[x.name][V.dataIndex],"onUpdate:value":S=>s.value[x.name][V.dataIndex]=S,onBlur:S=>d(x,V.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(C||" "),1)],64))],10,cd)):i.createCommentVNode("",!0),["dataLen","dataPrec"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(w,{key:0,value:s.value[x.name][V.dataIndex],"onUpdate:value":S=>s.value[x.name][V.dataIndex]=S,onBlur:S=>d(x,V.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(C||" "),1)],64))],10,hd)):["dataType"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(g,{key:0,value:x[V.dataIndex],"onUpdate:value":S=>x[V.dataIndex]=S,onBlur:b[0]||(b[0]=S=>d())},{default:i.withCtx(()=>[i.createVNode(O,{key:"String",value:"String"}),i.createVNode(O,{key:"Long",value:"Long"}),i.createVNode(O,{key:"Short",value:"Short"}),i.createVNode(O,{key:"Integer",value:"Integer"}),i.createVNode(O,{key:"Float",value:"Float"}),i.createVNode(O,{key:"Double",value:"Double"}),i.createVNode(O,{key:"Date",value:"Date"}),i.createVNode(O,{key:"Timestamp",value:"Timestamp"})]),_:2},1032,["value","onUpdate:value"])),[[l]]):(i.openBlock(),i.createElementBlock("span",ud,i.toDisplayString(C),1))],10,fd)):["syncEnable","isFk","isPk"].includes(V.dataIndex)?(i.openBlock(),i.createBlock(p,{key:3,checked:h(x,V.dataIndex),onClick:S=>f(x,V.dataIndex)},null,8,["checked","onClick"])):["isNull"].includes(V.dataIndex)?(i.openBlock(),i.createBlock(p,{key:4,checked:!h(x,V.dataIndex),onClick:S=>f(x,V.dataIndex)},null,8,["checked","onClick"])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])])}}}),[["__scopeId","data-v-4020e3f0"]]),Vl=1024;let md=0,ln=class{constructor(e,t){this.from=e,this.to=t}};class te{constructor(e={}){this.id=md++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ne.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}te.closedBy=new te({deserialize:o=>o.split(" ")}),te.openedBy=new te({deserialize:o=>o.split(" ")}),te.group=new te({deserialize:o=>o.split(" ")}),te.isolate=new te({deserialize:o=>{if(o&&o!="rtl"&&o!="ltr"&&o!="auto")throw new RangeError("Invalid value for isolate: "+o);return o||"auto"}}),te.contextHash=new te({perNode:!0}),te.lookAhead=new te({perNode:!0}),te.mounted=new te({perNode:!0});class hi{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[te.mounted.id]}}const gd=Object.create(null);class Ne{constructor(e,t,n,l=0){this.name=e,this.props=t,this.id=n,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):gd,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new Ne(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(l)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return l}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let l of n.split(" "))t[l]=e[n];return n=>{for(let l=n.prop(te.group),s=-1;s<(l?l.length:0);s++){let a=t[s<0?n.name:l[s]];if(a)return a}}}}Ne.none=new Ne("",Object.create(null),0,8);class sn{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let l=null;for(let s of e){let a=s(n);a&&(l||(l=Object.assign({},n.props)),l[a[0].id]=a[1])}t.push(l?new Ne(n.name,l,n.id,n.flags):n)}return new sn(t)}}const fi=new WeakMap,_l=new WeakMap;var pe;(function(o){o[o.ExcludeBuffers=1]="ExcludeBuffers",o[o.IncludeAnonymous=2]="IncludeAnonymous",o[o.IgnoreMounts=4]="IgnoreMounts",o[o.IgnoreOverlays=8]="IgnoreOverlays"})(pe||(pe={}));class he{constructor(e,t,n,l,s){if(this.type=e,this.children=t,this.positions=n,this.length=l,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,r]of s)this.props[typeof a=="number"?a:a.id]=r}}toString(){let e=hi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let l=n.toString();l&&(t&&(t+=","),t+=l)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new rn(this.topNode,e)}cursorAt(e,t=0,n=0){let l=fi.get(this)||this.topNode,s=new rn(l);return s.moveTo(e,t),fi.set(this,s._tree),s}get topNode(){return new Me(this,0,0,null)}resolve(e,t=0){let n=qt(fi.get(this)||this.topNode,e,t,!1);return fi.set(this,n),n}resolveInner(e,t=0){let n=qt(_l.get(this)||this.topNode,e,t,!0);return _l.set(this,n),n}resolveStack(e,t=0){return yd(this,e,t)}iterate(e){let{enter:t,leave:n,from:l=0,to:s=this.length}=e,a=e.mode||0,r=(a&pe.IncludeAnonymous)>0;for(let d=this.cursor(a|pe.IncludeAnonymous);;){let h=!1;if(d.from<=s&&d.to>=l&&(!r&&d.type.isAnonymous||t(d)!==!1)){if(d.firstChild())continue;h=!0}for(;h&&n&&(r||!d.type.isAnonymous)&&n(d),!d.nextSibling();){if(!d.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:cn(Ne.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,l)=>new he(this.type,t,n,l,this.propValues),e.makeTree||((t,n,l)=>new he(Ne.none,t,n,l)))}static build(e){return wd(e)}}he.empty=new he(Ne.none,[],[],0);class on{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new on(this.buffer,this.index)}}class tt{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ne.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],l=this.set.types[t],s=l.name;if(/\W/.test(s)&&!l.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return s+"("+a.join(",")+")"}findChild(e,t,n,l,s){let{buffer:a}=this,r=-1;for(let d=e;d!=t&&!(Ml(s,l,a[d+1],a[d+2])&&(r=d,n>0));d=a[d+3]);return r}slice(e,t,n){let l=this.buffer,s=new Uint16Array(t-e),a=0;for(let r=e,d=0;r<t;){s[d++]=l[r++],s[d++]=l[r++]-n;let h=s[d++]=l[r++]-n;s[d++]=l[r++]-e,a=Math.max(a,h)}return new tt(s,a,this.set)}}function Ml(o,e,t,n){switch(o){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function qt(o,e,t,n){for(var l;o.from==o.to||(t<1?o.from>=e:o.from>e)||(t>-1?o.to<=e:o.to<e);){let a=!n&&o instanceof Me&&o.index<0?null:o.parent;if(!a)return o;o=a}let s=n?0:pe.IgnoreOverlays;if(n)for(let a=o,r=a.parent;r;a=r,r=a.parent)a instanceof Me&&a.index<0&&((l=r.enter(e,t,s))===null||l===void 0?void 0:l.from)!=a.from&&(o=r);for(;;){let a=o.enter(e,t,s);if(!a)return o;o=a}}class Tl{cursor(e=0){return new rn(this,e)}getChild(e,t=null,n=null){let l=Al(this,e,t,n);return l.length?l[0]:null}getChildren(e,t=null,n=null){return Al(this,e,t,n)}resolve(e,t=0){return qt(this,e,t,!1)}resolveInner(e,t=0){return qt(this,e,t,!0)}matchContext(e){return an(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let l=t.lastChild;if(!l||l.to!=t.to)break;l.type.isError&&l.from==l.to?(n=t,t=l.prevSibling):t=l}return n}get node(){return this}get next(){return this.parent}}class Me extends Tl{constructor(e,t,n,l){super(),this._tree=e,this.from=t,this.index=n,this._parent=l}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,l,s=0){for(let a=this;;){for(let{children:r,positions:d}=a._tree,h=t>0?r.length:-1;e!=h;e+=t){let f=r[e],c=d[e]+a.from;if(Ml(l,n,c,c+f.length)){if(f instanceof tt){if(s&pe.ExcludeBuffers)continue;let u=f.findChild(0,f.buffer.length,t,n-c,l);if(u>-1)return new it(new kd(a,f,e,c),null,u)}else if(s&pe.IncludeAnonymous||!f.type.isAnonymous||dn(f)){let u;if(!(s&pe.IgnoreMounts)&&(u=hi.get(f))&&!u.overlay)return new Me(u.tree,c,e,a);let m=new Me(f,c,e,a);return s&pe.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?f.children.length-1:0,t,n,l)}}}if(s&pe.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let l;if(!(n&pe.IgnoreOverlays)&&(l=hi.get(this._tree))&&l.overlay){let s=e-this.from;for(let{from:a,to:r}of l.overlay)if((t>0?a<=s:a<s)&&(t<0?r>=s:r>s))return new Me(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Al(o,e,t,n){let l=o.cursor(),s=[];if(!l.firstChild())return s;if(t!=null){for(let a=!1;!a;)if(a=l.type.is(t),!l.nextSibling())return s}for(;;){if(n!=null&&l.type.is(n))return s;if(l.type.is(e)&&s.push(l.node),!l.nextSibling())return n==null?s:[]}}function an(o,e,t=e.length-1){for(let n=o.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class kd{constructor(e,t,n,l){this.parent=e,this.buffer=t,this.index=n,this.start=l}}class it extends Tl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:l}=this.context,s=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new it(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&pe.ExcludeBuffers)return null;let{buffer:l}=this.context,s=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new it(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new it(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new it(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,l=this.index+4,s=n.buffer[this.index+3];if(s>l){let a=n.buffer[this.index+1];e.push(n.slice(l,s,a)),t.push(0)}return new he(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function El(o){if(!o.length)return null;let e=0,t=o[0];for(let s=1;s<o.length;s++){let a=o[s];(a.from>t.from||a.to<t.to)&&(t=a,e=s)}let n=t instanceof Me&&t.index<0?null:t.parent,l=o.slice();return n?l[e]=n:l.splice(e,1),new bd(l,t)}class bd{constructor(e,t){this.heads=e,this.node=t}get next(){return El(this.heads)}}function yd(o,e,t){let n=o.resolveInner(e,t),l=null;for(let s=n instanceof Me?n:n.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(l||(l=[n])).push(a.resolve(e,t)),s=a}else{let a=hi.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=e&&a.overlay[a.overlay.length-1].to>=e){let r=new Me(a.tree,a.overlay[0].from+s.from,-1,s);(l||(l=[n])).push(qt(r,e,t,!1))}}return l?El(l):n}class rn{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Me)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=n+l.buffer[e+1],this.to=n+l.buffer[e+2],!0}yield(e){return e?e instanceof Me?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:l}=this.buffer,s=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&pe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&pe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&pe.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let l=n<0?0:this.stack[n]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(l)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:l}=this;if(l){if(e>0){if(this.index<l.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(l.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=l)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,a=e<0?-1:n._tree.children.length;s!=a;s+=e){let r=n._tree.children[s];if(this.mode&pe.IncludeAnonymous||r instanceof tt||!r.type.isAnonymous||dn(r))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let l=this.index,s=this.stack.length;s>=0;){for(let a=e;a;a=a._parent)if(a.index==l){if(l==this.index)return a;t=a,n=s+1;break e}l=this.stack[--s]}for(let l=n;l<this.stack.length;l++)t=new it(this.buffer,t,this.stack[l]);return this.bufferNode=new it(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let l=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(l=!0)}for(;l&&t&&t(this),l=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,l=!0}}}matchContext(e){if(!this.buffer)return an(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let l=e.length-1,s=this.stack.length-1;l>=0;s--){if(s<0)return an(this.node,e,l);let a=n[t.buffer[this.stack[s]]];if(!a.isAnonymous){if(e[l]&&e[l]!=a.name)return!1;l--}}return!0}}function dn(o){return o.children.some(e=>e instanceof tt||!e.type.isAnonymous||dn(e))}function wd(o){var e;let{buffer:t,nodeSet:n,maxBufferLength:l=Vl,reused:s=[],minRepeatType:a=n.types.length}=o,r=Array.isArray(t)?new on(t,t.length):t,d=n.types,h=0,f=0;function c(p,N,V,C,x,S){let{id:M,start:T,end:E,size:I}=r,L=f;for(;I<0;)if(r.next(),I==-1){let j=s[M];V.push(j),C.push(T-p);return}else if(I==-3){h=M;return}else if(I==-4){f=M;return}else throw new RangeError(`Unrecognized record size: ${I}`);let A=d[M],U,P,G=T-p;if(E-T<=l&&(P=k(r.pos-N,x))){let j=new Uint16Array(P.size-P.skip),B=r.pos-P.size,F=j.length;for(;r.pos>B;)F=v(P.start,j,F);U=new tt(j,E-P.start,n),G=P.start-p}else{let j=r.pos-I;r.next();let B=[],F=[],_=M>=a?M:-1,D=0,$=E;for(;r.pos>j;)_>=0&&r.id==_&&r.size>=0?(r.end<=$-l&&(b(B,F,T,D,r.end,$,_,L),D=B.length,$=r.end),r.next()):S>2500?u(T,j,B,F):c(T,j,B,F,_,S+1);if(_>=0&&D>0&&D<B.length&&b(B,F,T,D,T,$,_,L),B.reverse(),F.reverse(),_>-1&&D>0){let Q=m(A);U=cn(A,B,F,0,B.length,0,E-T,Q,Q)}else U=y(A,B,F,E-T,L-E)}V.push(U),C.push(G)}function u(p,N,V,C){let x=[],S=0,M=-1;for(;r.pos>N;){let{id:T,start:E,end:I,size:L}=r;if(L>4)r.next();else{if(M>-1&&E<M)break;M<0&&(M=I-l),x.push(T,E,I),S++,r.next()}}if(S){let T=new Uint16Array(S*4),E=x[x.length-2];for(let I=x.length-3,L=0;I>=0;I-=3)T[L++]=x[I],T[L++]=x[I+1]-E,T[L++]=x[I+2]-E,T[L++]=L;V.push(new tt(T,x[2]-E,n)),C.push(E-p)}}function m(p){return(N,V,C)=>{let x=0,S=N.length-1,M,T;if(S>=0&&(M=N[S])instanceof he){if(!S&&M.type==p&&M.length==C)return M;(T=M.prop(te.lookAhead))&&(x=V[S]+M.length+T)}return y(p,N,V,C,x)}}function b(p,N,V,C,x,S,M,T){let E=[],I=[];for(;p.length>C;)E.push(p.pop()),I.push(N.pop()+V-x);p.push(y(n.types[M],E,I,S-x,T-S)),N.push(x-V)}function y(p,N,V,C,x=0,S){if(h){let M=[te.contextHash,h];S=S?[M].concat(S):[M]}if(x>25){let M=[te.lookAhead,x];S=S?[M].concat(S):[M]}return new he(p,N,V,C,S)}function k(p,N){let V=r.fork(),C=0,x=0,S=0,M=V.end-l,T={size:0,start:0,skip:0};e:for(let E=V.pos-p;V.pos>E;){let I=V.size;if(V.id==N&&I>=0){T.size=C,T.start=x,T.skip=S,S+=4,C+=4,V.next();continue}let L=V.pos-I;if(I<0||L<E||V.start<M)break;let A=V.id>=a?4:0,U=V.start;for(V.next();V.pos>L;){if(V.size<0)if(V.size==-3)A+=4;else break e;else V.id>=a&&(A+=4);V.next()}x=U,C+=I,S+=A}return(N<0||C==p)&&(T.size=C,T.start=x,T.skip=S),T.size>4?T:void 0}function v(p,N,V){let{id:C,start:x,end:S,size:M}=r;if(r.next(),M>=0&&C<a){let T=V;if(M>4){let E=r.pos-(M-4);for(;r.pos>E;)V=v(p,N,V)}N[--V]=T,N[--V]=S-p,N[--V]=x-p,N[--V]=C}else M==-3?h=C:M==-4&&(f=C);return V}let w=[],O=[];for(;r.pos>0;)c(o.start||0,o.bufferStart||0,w,O,-1,0);let g=(e=o.length)!==null&&e!==void 0?e:w.length?O[0]+w[0].length:0;return new he(d[o.topID],w.reverse(),O.reverse(),g)}const Il=new WeakMap;function ui(o,e){if(!o.isAnonymous||e instanceof tt||e.type!=o)return 1;let t=Il.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=o||!(n instanceof he)){t=1;break}t+=ui(o,n)}Il.set(e,t)}return t}function cn(o,e,t,n,l,s,a,r,d){let h=0;for(let b=n;b<l;b++)h+=ui(o,e[b]);let f=Math.ceil(h*1.5/8),c=[],u=[];function m(b,y,k,v,w){for(let O=k;O<v;){let g=O,p=y[O],N=ui(o,b[O]);for(O++;O<v;O++){let V=ui(o,b[O]);if(N+V>=f)break;N+=V}if(O==g+1){if(N>f){let V=b[g];m(V.children,V.positions,0,V.children.length,y[g]+w);continue}c.push(b[g])}else{let V=y[O-1]+b[O-1].length-p;c.push(cn(o,b,y,g,O,p,V,null,d))}u.push(p+w-s)}}return m(e,t,n,l,0),(r||d)(c,u,a)}class ut{constructor(e,t,n,l,s=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=l,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let l=[new ut(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&l.push(s);return l}static applyChanges(e,t,n=128){if(!t.length)return e;let l=[],s=1,a=e.length?e[0]:null;for(let r=0,d=0,h=0;;r++){let f=r<t.length?t[r]:null,c=f?f.fromA:1e9;if(c-d>=n)for(;a&&a.from<c;){let u=a;if(d>=u.from||c<=u.to||h){let m=Math.max(u.from,d)-h,b=Math.min(u.to,c)-h;u=m>=b?null:new ut(m,b,u.tree,u.offset+h,r>0,!!f)}if(u&&l.push(u),a.to>c)break;a=s<e.length?e[s++]:null}if(!f)break;d=f.toA,h=f.toA-f.toB}return l}}class Dl{startParse(e,t,n){return typeof e=="string"&&(e=new xd(e)),n=n?n.length?n.map(l=>new ln(l.from,l.to)):[new ln(0,0)]:[new ln(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let l=this.startParse(e,t,n);for(;;){let s=l.advance();if(s)return s}}}class xd{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new te({perNode:!0});class pi{constructor(e,t,n,l,s,a,r,d,h,f=0,c){this.p=e,this.stack=t,this.state=n,this.reducePos=l,this.pos=s,this.score=a,this.buffer=r,this.bufferBase=d,this.curContext=h,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let l=e.parser.context;return new pi(e,[],t,n,n,0,[],0,l?new Pl(l,l.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,l=e&65535,{parser:s}=this.p,a=this.reducePos<this.pos-25;a&&this.setLookAhead(this.pos);let r=s.dynamicPrecedence(l);if(r&&(this.score+=r),n==0){this.pushState(s.getGoto(this.state,l,!0),this.reducePos),l<s.minRepeatTerm&&this.storeNode(l,this.reducePos,this.reducePos,a?8:4,!0),this.reduceContext(l,this.reducePos);return}let d=this.stack.length-(n-1)*3-(e&262144?6:0),h=d?this.stack[d-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let c=d?this.stack[d-1]:0,u=this.bufferBase+this.buffer.length-c;if(l<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(l,h,m,u+4,!0)}if(e&262144)this.state=this.stack[d];else{let m=this.stack[d-3];this.state=s.getGoto(m,l,!0)}for(;this.stack.length>d;)this.stack.pop();this.reduceContext(l,h)}storeNode(e,t,n,l=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let a=this,r=this.buffer.length;if(r==0&&a.parent&&(r=a.bufferBase-a.parent.bufferBase,a=a.parent),r>0&&a.buffer[r-4]==0&&a.buffer[r-1]>-1){if(t==n)return;if(a.buffer[r-2]>=t){a.buffer[r-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,l);else{let a=this.buffer.length;if(a>0&&this.buffer[a-4]!=0){let r=!1;for(let d=a;d>0&&this.buffer[d-2]>n;d-=4)if(this.buffer[d-1]>=0){r=!0;break}if(r)for(;a>0&&this.buffer[a-2]>n;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,l>4&&(l-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=n,this.buffer[a+3]=l}}shift(e,t,n,l){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=l,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,l,4);else{let s=e,{parser:a}=this.p;(l>this.pos||t<=a.maxNode)&&(this.pos=l,a.stateFlag(s,1)||(this.reducePos=l)),this.pushState(s,n),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,l,4)}}apply(e,t,n,l){e&65536?this.reduce(e):this.shift(e,t,n,l)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let l=this.pos;this.reducePos=this.pos=l+e.length,this.pushState(t,l),this.buffer.push(n,l,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new pi(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new vd(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let l=[];for(let s=0,a;s<t.length;s+=2)(a=t[s+1])!=this.state&&this.p.parser.hasAction(a,e)&&l.push(t[s],a);if(this.stack.length<120)for(let s=0;l.length<8&&s<t.length;s+=2){let a=t[s+1];l.some((r,d)=>d&1&&r==a)||l.push(t[s],a)}t=l}let n=[];for(let l=0;l<t.length&&n.length<4;l+=2){let s=t[l+1];if(s==this.state)continue;let a=this.split();a.pushState(s,this.pos),a.storeNode(0,a.pos,a.pos,4,!0),a.shiftContext(t[l],this.pos),a.reducePos=this.pos,a.score-=200,n.push(a)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,l=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],l,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(l,s)=>{if(!t.includes(l))return t.push(l),e.allActions(l,a=>{if(!(a&393216))if(a&65536){let r=(a>>19)-s;if(r>1){let d=a&65535,h=this.stack.length-r*3;if(h>=0&&e.getGoto(this.stack[h],d,!1)>=0)return r<<19|65536|d}}else{let r=n(a,s+1);if(r!=null)return r}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Pl(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Pl{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class vd{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class mi{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new mi(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new mi(this.stack,this.pos,this.index)}}function gi(o,e=Uint16Array){if(typeof o!="string")return o;let t=null;for(let n=0,l=0;n<o.length;){let s=0;for(;;){let a=o.charCodeAt(n++),r=!1;if(a==126){s=65535;break}a>=92&&a--,a>=34&&a--;let d=a-32;if(d>=46&&(d-=46,r=!0),s+=d,r)break;s*=46}t?t[l++]=s:t=new e(s)}return t}class ki{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Fl=new ki;class Cd{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Fl,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,l=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!l)return null;let a=this.ranges[--l];s-=n.from-a.to,n=a}for(;t<0?s>n.to:s>=n.to;){if(l==this.ranges.length-1)return null;let a=this.ranges[++l];s+=a.from-n.to,n=a}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,l;if(t>=0&&t<this.chunk.length)n=this.pos+e,l=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)l=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let a=this.rangeIndex,r=this.range;for(;r.to<=n;)r=this.ranges[++a];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-n)),l=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),l}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Fl,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(n+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return n}}class vt{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Sd(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}vt.prototype.contextual=vt.prototype.fallback=vt.prototype.extend=!1,vt.prototype.fallback=vt.prototype.extend=!1;function Sd(o,e,t,n,l,s){let a=0,r=1<<n,{dialect:d}=t.p.parser;e:for(;r&o[a];){let h=o[a+1];for(let m=a+3;m<h;m+=2)if((o[m+1]&r)>0){let b=o[m];if(d.allows(b)&&(e.token.value==-1||e.token.value==b||Nd(b,e.token.value,l,s))){e.acceptToken(b);break}}let f=e.next,c=0,u=o[a+2];if(e.next<0&&u>c&&o[h+u*3-3]==65535){a=o[h+u*3-1];continue e}for(;c<u;){let m=c+u>>1,b=h+m+(m<<1),y=o[b],k=o[b+1]||65536;if(f<y)u=m;else if(f>=k)c=m+1;else{a=o[b+2],e.advance();continue e}}break}}function $l(o,e,t){for(let n=e,l;(l=o[n])!=65535;n++)if(l==t)return n-e;return-1}function Nd(o,e,t,n){let l=$l(t,n,e);return l<0||$l(t,n,o)<l}const Oe=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let hn=null;function Rl(o,e,t){let n=o.cursor(pe.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(o.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:o.length}}class Bd{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Rl(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Rl(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],l=this.index[t];if(l==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[l],a=this.start[t]+n.positions[l];if(a>e)return this.nextStart=a,null;if(s instanceof he){if(a==e){if(a<this.safeFrom)return null;let r=a+s.length;if(r<=this.safeTo){let d=s.prop(te.lookAhead);if(!d||r+d<this.fragment.to)return s}}this.index[t]++,a+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+s.length}}}class Od{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new ki)}getActions(e){let t=0,n=null,{parser:l}=e.p,{tokenizers:s}=l,a=l.stateSlot(e.state,3),r=e.curContext?e.curContext.hash:0,d=0;for(let h=0;h<s.length;h++){if(!(1<<h&a))continue;let f=s[h],c=this.tokens[h];if(!(n&&!f.fallback)&&((f.contextual||c.start!=e.pos||c.mask!=a||c.context!=r)&&(this.updateCachedToken(c,f,e),c.mask=a,c.context=r),c.lookAhead>c.end+25&&(d=Math.max(c.lookAhead,d)),c.value!=0)){let u=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!f.extend&&(n=c,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return d&&e.setLookAhead(d),!n&&e.pos==this.stream.end&&(n=new ki,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ki,{pos:n,p:l}=e;return t.start=n,t.end=Math.min(n+1,l.stream.end),t.value=n==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,n){let l=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(l,e),n),e.value>-1){let{parser:s}=n.p;for(let a=0;a<s.specialized.length;a++)if(s.specialized[a]==e.value){let r=s.specializers[a](this.stream.read(e.start,e.end),n);if(r>=0&&n.p.parser.dialect.allows(r>>1)){r&1?e.extended=r>>1:e.value=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,n,l){for(let s=0;s<l;s+=3)if(this.actions[s]==e)return l;return this.actions[l++]=e,this.actions[l++]=t,this.actions[l++]=n,l}addActions(e,t,n,l){let{state:s}=e,{parser:a}=e.p,{data:r}=a;for(let d=0;d<2;d++)for(let h=a.stateSlot(s,d?2:1);;h+=3){if(r[h]==65535)if(r[h+1]==1)h=Qe(r,h+2);else{l==0&&r[h+1]==2&&(l=this.putAction(Qe(r,h+2),t,n,l));break}r[h]==t&&(l=this.putAction(Qe(r,h+1),t,n,l))}return l}}class Vd{constructor(e,t,n,l){this.parser=e,this.input=t,this.ranges=l,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Cd(t,l),this.tokens=new Od(e,this.stream),this.topTerm=e.top[1];let{from:s}=l[0];this.stacks=[pi.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new Bd(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],l,s;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let r=e[a];for(;;){if(this.tokens.mainToken=null,r.pos>t)n.push(r);else{if(this.advanceStack(r,n,e))continue;{l||(l=[],s=[]),l.push(r);let d=this.tokens.getMainToken(r);s.push(d.value,d.end)}}break}}if(!n.length){let a=l&&Md(l);if(a)return Oe&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Oe&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let a=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,s,n);if(a)return Oe&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(n.length>a)for(n.sort((r,d)=>d.score-r.score);n.length>a;)n.pop();n.some(r=>r.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let a=0;a<n.length-1;a++){let r=n[a];for(let d=a+1;d<n.length;d++){let h=n[d];if(r.sameState(h)||r.buffer.length>500&&h.buffer.length>500)if((r.score-h.score||r.buffer.length-h.buffer.length)>0)n.splice(d--,1);else{n.splice(a--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let a=1;a<n.length;a++)n[a].pos<this.minStackPos&&(this.minStackPos=n[a].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let l=e.pos,{parser:s}=this,a=Oe?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,f=h?e.curContext.hash:0;for(let c=this.fragments.nodeAt(l);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?s.getGoto(e.state,c.type.id):-1;if(u>-1&&c.length&&(!h||(c.prop(te.contextHash)||0)==f))return e.useNode(c,u),Oe&&console.log(a+this.stackID(e)+` (via reuse of ${s.getName(c.type.id)})`),!0;if(!(c instanceof he)||c.children.length==0||c.positions[0]>0)break;let m=c.children[0];if(m instanceof he&&c.positions[0]==0)c=m;else break}}let r=s.stateSlot(e.state,4);if(r>0)return e.reduce(r),Oe&&console.log(a+this.stackID(e)+` (via always-reduce ${s.getName(r&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let d=this.tokens.getActions(e);for(let h=0;h<d.length;){let f=d[h++],c=d[h++],u=d[h++],m=h==d.length||!n,b=m?e:e.split(),y=this.tokens.mainToken;if(b.apply(f,c,y?y.start:b.pos,u),Oe&&console.log(a+this.stackID(b)+` (via ${f&65536?`reduce of ${s.getName(f&65535)}`:"shift"} for ${s.getName(c)} @ ${l}${b==e?"":", split"})`),m)return!0;b.pos>l?t.push(b):n.push(b)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Ll(e,t),!0}}runRecovery(e,t,n){let l=null,s=!1;for(let a=0;a<e.length;a++){let r=e[a],d=t[a<<1],h=t[(a<<1)+1],f=Oe?this.stackID(r)+" -> ":"";if(r.deadEnd&&(s||(s=!0,r.restart(),Oe&&console.log(f+this.stackID(r)+" (restarted)"),this.advanceFully(r,n))))continue;let c=r.split(),u=f;for(let m=0;c.forceReduce()&&m<10&&(Oe&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,n));m++)Oe&&(u=this.stackID(c)+" -> ");for(let m of r.recoverByInsert(d))Oe&&console.log(f+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,n);this.stream.end>r.pos?(h==r.pos&&(h++,d=0),r.recoverByDelete(d,h),Oe&&console.log(f+this.stackID(r)+` (via recover-delete ${this.parser.getName(d)})`),Ll(r,n)):(!l||l.score<r.score)&&(l=r)}return l}stackToTree(e){return e.close(),he.build({buffer:mi.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(hn||(hn=new WeakMap)).get(e);return t||hn.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Ll(o,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==o.pos&&n.sameState(o)){e[t].score<o.score&&(e[t]=o);return}}e.push(o)}class _d{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class bi extends Dl{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let r=0;r<e.repeatNodeCount;r++)t.push("");let n=Object.keys(e.topRules).map(r=>e.topRules[r][1]),l=[];for(let r=0;r<t.length;r++)l.push([]);function s(r,d,h){l[r].push([d,d.deserialize(String(h))])}if(e.nodeProps)for(let r of e.nodeProps){let d=r[0];typeof d=="string"&&(d=te[d]);for(let h=1;h<r.length;){let f=r[h++];if(f>=0)s(f,d,r[h++]);else{let c=r[h+-f];for(let u=-f;u>0;u--)s(r[h++],d,c);h++}}}this.nodeSet=new sn(t.map((r,d)=>Ne.define({name:d>=this.minRepeatTerm?void 0:r,id:d,props:l[d],top:n.indexOf(d)>-1,error:d==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(d)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Vl;let a=gi(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let r=0;r<this.specializerSpecs.length;r++)this.specialized[r]=this.specializerSpecs[r].term;this.specializers=this.specializerSpecs.map(jl),this.states=gi(e.states,Uint32Array),this.data=gi(e.stateData),this.goto=gi(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(r=>typeof r=="number"?new vt(a,r):r),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let l=new Vd(this,e,t,n);for(let s of this.wrappers)l=s(l,e,t,n);return l}getGoto(e,t,n=!1){let l=this.goto;if(t>=l[0])return-1;for(let s=l[t+1];;){let a=l[s++],r=a&1,d=l[s++];if(r&&n)return d;for(let h=s+(a>>1);s<h;s++)if(l[s]==e)return d;if(r)return-1}}hasAction(e,t){let n=this.data;for(let l=0;l<2;l++)for(let s=this.stateSlot(e,l?2:1),a;;s+=3){if((a=n[s])==65535)if(n[s+1]==1)a=n[s=Qe(n,s+2)];else{if(n[s+1]==2)return Qe(n,s+2);break}if(a==t||a==0)return Qe(n,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),l=n?t(n):void 0;for(let s=this.stateSlot(e,1);l==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Qe(this.data,s+2);else break;l=t(Qe(this.data,s+1))}return l}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Qe(this.data,n+2);else break;if(!(this.data[n+2]&1)){let l=this.data[n+1];t.some((s,a)=>a&1&&s==l)||t.push(this.data[n],l)}}return t}configure(e){let t=Object.assign(Object.create(bi.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let l=e.tokenizers.find(s=>s.from==n);return l?l.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,l)=>{let s=e.specializers.find(r=>r.from==n.external);if(!s)return n;let a=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[l]=jl(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let a=t.indexOf(s);a>=0&&(n[a]=!0)}let l=null;for(let s=0;s<t.length;s++)if(!n[s])for(let a=this.dialects[t[s]],r;(r=this.data[a++])!=65535;)(l||(l=new Uint8Array(this.maxTerm+1)))[r]=1;return new _d(e,n,l)}static deserialize(e){return new bi(e)}}function Qe(o,e){return o[e]|o[e+1]<<16}function Md(o){let e=null;for(let t of o){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function jl(o){if(o.external){let e=o.extend?1:0;return(t,n)=>o.external(t,n)<<1|e}return o.get}let Td=0;class Te{constructor(e,t,n,l){this.name=e,this.set=t,this.base=n,this.modified=l,this.id=Td++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Te&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let l=new Te(n,[],null,[]);if(l.set.push(l),t)for(let s of t.set)l.set.push(s);return l}static defineModifier(e){let t=new yi(e);return n=>n.modified.indexOf(t)>-1?n:yi.get(n.base||n,n.modified.concat(t).sort((l,s)=>l.id-s.id))}}let Ad=0;class yi{constructor(e){this.name=e,this.instances=[],this.id=Ad++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(r=>r.base==e&&Ed(t,r.modified));if(n)return n;let l=[],s=new Te(e.name,l,e,t);for(let r of t)r.instances.push(s);let a=Id(t);for(let r of e.set)if(!r.modified.length)for(let d of a)l.push(yi.get(r,d));return s}}function Ed(o,e){return o.length==e.length&&o.every((t,n)=>t==e[n])}function Id(o){let e=[[]];for(let t=0;t<o.length;t++)for(let n=0,l=e.length;n<l;n++)e.push(e[n].concat(o[t]));return e.sort((t,n)=>n.length-t.length)}function zl(o){let e=Object.create(null);for(let t in o){let n=o[t];Array.isArray(n)||(n=[n]);for(let l of t.split(" "))if(l){let s=[],a=2,r=l;for(let c=0;;){if(r=="..."&&c>0&&c+3==l.length){a=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!u)throw new RangeError("Invalid path: "+l);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==l.length)break;let m=l[c++];if(c==l.length&&m=="!"){a=0;break}if(m!="/")throw new RangeError("Invalid path: "+l);r=l.slice(c)}let d=s.length-1,h=s[d];if(!h)throw new RangeError("Invalid path: "+l);let f=new fn(n,a,d>0?s.slice(0,d):null);e[h]=f.sort(e[h])}}return Dd.add(e)}const Dd=new te;class fn{constructor(e,t,n,l){this.tags=e,this.mode=t,this.context=n,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}fn.empty=new fn([],2,null);function ql(o,e){let t=Object.create(null);for(let s of o)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let a of s.tag)t[a.id]=s.class;let{scope:n,all:l=null}=e||{};return{style:s=>{let a=l;for(let r of s)for(let d of r.set){let h=t[d.id];if(h){a=a?a+" "+h:h;break}}return a},scope:n}}const q=Te.define,wi=q(),nt=q(),Ul=q(nt),Wl=q(nt),lt=q(),xi=q(lt),un=q(lt),$e=q(),pt=q($e),Re=q(),Le=q(),pn=q(),Ut=q(pn),vi=q(),z={comment:wi,lineComment:q(wi),blockComment:q(wi),docComment:q(wi),name:nt,variableName:q(nt),typeName:Ul,tagName:q(Ul),propertyName:Wl,attributeName:q(Wl),className:q(nt),labelName:q(nt),namespace:q(nt),macroName:q(nt),literal:lt,string:xi,docString:q(xi),character:q(xi),attributeValue:q(xi),number:un,integer:q(un),float:q(un),bool:q(lt),regexp:q(lt),escape:q(lt),color:q(lt),url:q(lt),keyword:Re,self:q(Re),null:q(Re),atom:q(Re),unit:q(Re),modifier:q(Re),operatorKeyword:q(Re),controlKeyword:q(Re),definitionKeyword:q(Re),moduleKeyword:q(Re),operator:Le,derefOperator:q(Le),arithmeticOperator:q(Le),logicOperator:q(Le),bitwiseOperator:q(Le),compareOperator:q(Le),updateOperator:q(Le),definitionOperator:q(Le),typeOperator:q(Le),controlOperator:q(Le),punctuation:pn,separator:q(pn),bracket:Ut,angleBracket:q(Ut),squareBracket:q(Ut),paren:q(Ut),brace:q(Ut),content:$e,heading:pt,heading1:q(pt),heading2:q(pt),heading3:q(pt),heading4:q(pt),heading5:q(pt),heading6:q(pt),contentSeparator:q($e),list:q($e),quote:q($e),emphasis:q($e),strong:q($e),link:q($e),monospace:q($e),strikethrough:q($e),inserted:q(),deleted:q(),changed:q(),invalid:q(),meta:vi,documentMeta:q(vi),annotation:q(vi),processingInstruction:q(vi),definition:Te.defineModifier("definition"),constant:Te.defineModifier("constant"),function:Te.defineModifier("function"),standard:Te.defineModifier("standard"),local:Te.defineModifier("local"),special:Te.defineModifier("special")};for(let o in z){let e=z[o];e instanceof Te&&(e.name=o)}ql([{tag:z.link,class:"tok-link"},{tag:z.heading,class:"tok-heading"},{tag:z.emphasis,class:"tok-emphasis"},{tag:z.strong,class:"tok-strong"},{tag:z.keyword,class:"tok-keyword"},{tag:z.atom,class:"tok-atom"},{tag:z.bool,class:"tok-bool"},{tag:z.url,class:"tok-url"},{tag:z.labelName,class:"tok-labelName"},{tag:z.inserted,class:"tok-inserted"},{tag:z.deleted,class:"tok-deleted"},{tag:z.literal,class:"tok-literal"},{tag:z.string,class:"tok-string"},{tag:z.number,class:"tok-number"},{tag:[z.regexp,z.escape,z.special(z.string)],class:"tok-string2"},{tag:z.variableName,class:"tok-variableName"},{tag:z.local(z.variableName),class:"tok-variableName tok-local"},{tag:z.definition(z.variableName),class:"tok-variableName tok-definition"},{tag:z.special(z.variableName),class:"tok-variableName2"},{tag:z.definition(z.propertyName),class:"tok-propertyName tok-definition"},{tag:z.typeName,class:"tok-typeName"},{tag:z.namespace,class:"tok-namespace"},{tag:z.className,class:"tok-className"},{tag:z.macroName,class:"tok-macroName"},{tag:z.propertyName,class:"tok-propertyName"},{tag:z.operator,class:"tok-operator"},{tag:z.comment,class:"tok-comment"},{tag:z.meta,class:"tok-meta"},{tag:z.invalid,class:"tok-invalid"},{tag:z.punctuation,class:"tok-punctuation"}]);const Pd=zl({String:z.string,Number:z.number,"True False":z.bool,PropertyName:z.propertyName,Null:z.null,",":z.separator,"[ ]":z.squareBracket,"{ }":z.brace}),Fd=bi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[Pd],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});class ie{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ct(this,e,t);let l=[];return this.decompose(0,e,l,2),n.length&&n.decompose(0,n.length,l,3),this.decompose(t,this.length,l,1),je.from(l,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ct(this,e,t);let n=[];return this.decompose(e,t,n,0),je.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),l=new Wt(this),s=new Wt(e);for(let a=t,r=t;;){if(l.next(a),s.next(a),a=0,l.lineBreak!=s.lineBreak||l.done!=s.done||l.value!=s.value)return!1;if(r+=l.value.length,l.done||r>=n)return!0}}iter(e=1){return new Wt(this,e)}iterRange(e,t=this.length){return new Kl(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;n=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ql(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ie.empty:e.length<=32?new ce(e):je.from(ce.split(e,[]))}}class ce extends ie{constructor(e,t=$d(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,l){for(let s=0;;s++){let a=this.text[s],r=l+a.length;if((t?n:r)>=e)return new Rd(l,r,n,a);l=r+1,n++}}decompose(e,t,n,l){let s=e<=0&&t>=this.length?this:new ce(Hl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=n.pop(),r=Ci(s.text,a.text.slice(),0,s.length);if(r.length<=32)n.push(new ce(r,a.length+s.length));else{let d=r.length>>1;n.push(new ce(r.slice(0,d)),new ce(r.slice(d)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);[e,t]=Ct(this,e,t);let l=Ci(this.text,Ci(n.text,Hl(this.text,0,e)),t),s=this.length+n.length-(t-e);return l.length<=32?new ce(l,s):je.from(ce.split(l,[]),s)}sliceString(e,t=this.length,n=`
2
- `){[e,t]=Ct(this,e,t);let l="";for(let s=0,a=0;s<=t&&a<this.text.length;a++){let r=this.text[a],d=s+r.length;s>e&&a&&(l+=n),e<d&&t>s&&(l+=r.slice(Math.max(0,e-s),t-s)),s=d+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],l=-1;for(let s of e)n.push(s),l+=s.length+1,n.length==32&&(t.push(new ce(n,l)),n=[],l=-1);return l>-1&&t.push(new ce(n,l)),t}}class je extends ie{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,l){for(let s=0;;s++){let a=this.children[s],r=l+a.length,d=n+a.lines-1;if((t?d:r)>=e)return a.lineInner(e,t,n,l);l=r+1,n=d+1}}decompose(e,t,n,l){for(let s=0,a=0;a<=t&&s<this.children.length;s++){let r=this.children[s],d=a+r.length;if(e<=d&&t>=a){let h=l&((a<=e?1:0)|(d>=t?2:0));a>=e&&d<=t&&!h?n.push(r):r.decompose(e-a,t-a,n,h)}a=d+1}}replace(e,t,n){if([e,t]=Ct(this,e,t),n.lines<this.lines)for(let l=0,s=0;l<this.children.length;l++){let a=this.children[l],r=s+a.length;if(e>=s&&t<=r){let d=a.replace(e-s,t-s,n),h=this.lines-a.lines+d.lines;if(d.lines<h>>4&&d.lines>h>>6){let f=this.children.slice();return f[l]=d,new je(f,this.length-(t-e)+n.length)}return super.replace(s,r,d)}s=r+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
3
- `){[e,t]=Ct(this,e,t);let l="";for(let s=0,a=0;s<this.children.length&&a<=t;s++){let r=this.children[s],d=a+r.length;a>e&&s&&(l+=n),e<d&&t>a&&(l+=r.sliceString(e-a,t-a,n)),a=d+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof je))return 0;let n=0,[l,s,a,r]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,s+=t){if(l==a||s==r)return n;let d=this.children[l],h=e.children[s];if(d!=h)return n+d.scanIdentical(h,t);n+=d.length+1}}static from(e,t=e.reduce((n,l)=>n+l.length+1,-1)){let n=0;for(let m of e)n+=m.lines;if(n<32){let m=[];for(let b of e)b.flatten(m);return new ce(m,t)}let l=Math.max(32,n>>5),s=l<<1,a=l>>1,r=[],d=0,h=-1,f=[];function c(m){let b;if(m.lines>s&&m instanceof je)for(let y of m.children)c(y);else m.lines>a&&(d>a||!d)?(u(),r.push(m)):m instanceof ce&&d&&(b=f[f.length-1])instanceof ce&&m.lines+b.lines<=32?(d+=m.lines,h+=m.length+1,f[f.length-1]=new ce(b.text.concat(m.text),b.length+1+m.length)):(d+m.lines>l&&u(),d+=m.lines,h+=m.length+1,f.push(m))}function u(){d!=0&&(r.push(f.length==1?f[0]:je.from(f,h)),h=-1,d=f.length=0)}for(let m of e)c(m);return u(),r.length==1?r[0]:new je(r,t)}}ie.empty=new ce([""],0);function $d(o){let e=-1;for(let t of o)e+=t.length+1;return e}function Ci(o,e,t=0,n=1e9){for(let l=0,s=0,a=!0;s<o.length&&l<=n;s++){let r=o[s],d=l+r.length;d>=t&&(d>n&&(r=r.slice(0,n-l)),l<t&&(r=r.slice(t-l)),a?(e[e.length-1]+=r,a=!1):e.push(r)),l=d+1}return e}function Hl(o,e,t){return Ci(o,[""],e,t)}class Wt{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,l=this.nodes[n],s=this.offsets[n],a=s>>1,r=l instanceof ce?l.text.length:l.children.length;if(a==(t>0?r:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
4
- `,this;e--}else if(l instanceof ce){let d=l.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,d.length>Math.max(0,e))return this.value=e==0?d:t>0?d.slice(e):d.slice(0,d.length-e),this;e-=d.length}else{let d=l.children[a+(t<0?-1:0)];e>d.length?(e-=d.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(d),this.offsets.push(t>0?1:(d instanceof ce?d.text.length:d.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Kl{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Wt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=n?l:t<0?l.slice(l.length-n):l.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ql{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ie.prototype[Symbol.iterator]=function(){return this.iter()},Wt.prototype[Symbol.iterator]=Kl.prototype[Symbol.iterator]=Ql.prototype[Symbol.iterator]=function(){return this});class Rd{constructor(e,t,n,l){this.from=e,this.to=t,this.number=n,this.text=l}get length(){return this.to-this.from}}function Ct(o,e,t){return e=Math.max(0,Math.min(o.length,e)),[e,Math.max(e,Math.min(o.length,t))]}let St="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(o=>o?parseInt(o,36):1);for(let o=1;o<St.length;o++)St[o]+=St[o-1];function Ld(o){for(let e=1;e<St.length;e+=2)if(St[e]>o)return St[e-1]<=o;return!1}function Gl(o){return o>=127462&&o<=127487}const Yl=8205;function Ge(o,e,t=!0,n=!0){return(t?Xl:jd)(o,e,n)}function Xl(o,e,t){if(e==o.length)return e;e&&Jl(o.charCodeAt(e))&&Zl(o.charCodeAt(e-1))&&e--;let n=mn(o,e);for(e+=es(n);e<o.length;){let l=mn(o,e);if(n==Yl||l==Yl||t&&Ld(l))e+=es(l),n=l;else if(Gl(l)){let s=0,a=e-2;for(;a>=0&&Gl(mn(o,a));)s++,a-=2;if(s%2==0)break;e+=2}else break}return e}function jd(o,e,t){for(;e>0;){let n=Xl(o,e-2,t);if(n<e)return n;e--}return 0}function Jl(o){return o>=56320&&o<57344}function Zl(o){return o>=55296&&o<56320}function mn(o,e){let t=o.charCodeAt(e);if(!Zl(t)||e+1==o.length)return t;let n=o.charCodeAt(e+1);return Jl(n)?(t-55296<<10)+(n-56320)+65536:t}function es(o){return o<65536?1:2}const gn=/\r\n?|\n/;var Ve=function(o){return o[o.Simple=0]="Simple",o[o.TrackDel=1]="TrackDel",o[o.TrackBefore=2]="TrackBefore",o[o.TrackAfter=3]="TrackAfter",o}(Ve||(Ve={}));class Ye{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,l=0;t<this.sections.length;){let s=this.sections[t++],a=this.sections[t++];a<0?(e(n,l,s),l+=s):l+=a,n+=s}}iterChangedRanges(e,t=!1){kn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],l=this.sections[t++];l<0?e.push(n,l):e.push(l,n)}return new Ye(e)}composeDesc(e){return this.empty?e:e.empty?this:ts(this,e)}mapDesc(e,t=!1){return e.empty?this:bn(this,e,t)}mapPos(e,t=-1,n=Ve.Simple){let l=0,s=0;for(let a=0;a<this.sections.length;){let r=this.sections[a++],d=this.sections[a++],h=l+r;if(d<0){if(h>e)return s+(e-l);s+=r}else{if(n!=Ve.Simple&&h>=e&&(n==Ve.TrackDel&&l<e&&h>e||n==Ve.TrackBefore&&l<e||n==Ve.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!r)return e==l||t<0?s:s+d;s+=d}l=h}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return s}touchesRange(e,t=e){for(let n=0,l=0;n<this.sections.length&&l<=t;){let s=this.sections[n++],a=this.sections[n++],r=l+s;if(a>=0&&l<=t&&r>=e)return l<e&&r>t?"cover":!0;l=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],l=this.sections[t++];e+=(e?" ":"")+n+(l>=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ye(e)}static create(e){return new Ye(e)}}class me extends Ye{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return kn(this,(t,n,l,s,a)=>e=e.replace(l,l+(n-t),a),!1),e}mapDesc(e,t=!1){return bn(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let l=0,s=0;l<t.length;l+=2){let a=t[l],r=t[l+1];if(r>=0){t[l]=r,t[l+1]=a;let d=l>>1;for(;n.length<d;)n.push(ie.empty);n.push(a?e.slice(s,s+a):ie.empty)}s+=a}return new me(t,n)}compose(e){return this.empty?e:e.empty?this:ts(this,e,!0)}map(e,t=!1){return e.empty?this:bn(this,e,t,!0)}iterChanges(e,t=!1){kn(this,e,t)}get desc(){return Ye.create(this.sections)}filter(e){let t=[],n=[],l=[],s=new Ht(this);e:for(let a=0,r=0;;){let d=a==e.length?1e9:e[a++];for(;r<d||r==d&&s.len==0;){if(s.done)break e;let f=Math.min(s.len,d-r);we(l,f,-1);let c=s.ins==-1?-1:s.off==0?s.ins:0;we(t,f,c),c>0&&st(n,t,s.text),s.forward(f),r+=f}let h=e[a++];for(;r<h;){if(s.done)break e;let f=Math.min(s.len,h-r);we(t,f,-1),we(l,f,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(f),r+=f}}return{changes:new me(t,n),filtered:Ye.create(l)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],l=this.sections[t+1];l<0?e.push(n):l==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let l=[],s=[],a=0,r=null;function d(f=!1){if(!f&&!l.length)return;a<t&&we(l,t-a,-1);let c=new me(l,s);r=r?r.compose(c.map(r)):c,l=[],s=[],a=0}function h(f){if(Array.isArray(f))for(let c of f)h(c);else if(f instanceof me){if(f.length!=t)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${t})`);d(),r=r?r.compose(f.map(r)):f}else{let{from:c,to:u=c,insert:m}=f;if(c>u||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let b=m?typeof m=="string"?ie.of(m.split(n||gn)):m:ie.empty,y=b.length;if(c==u&&y==0)return;c<a&&d(),c>a&&we(l,c-a,-1),we(l,u-c,y),st(s,l,b),a=u}}return h(e),d(!r),r}static empty(e){return new me(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let l=0;l<e.length;l++){let s=e[l];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((a,r)=>r&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<l;)n.push(ie.empty);n[l]=ie.of(s.slice(1)),t.push(s[0],n[l].length)}}}return new me(t,n)}static createSet(e,t){return new me(e,t)}}function we(o,e,t,n=!1){if(e==0&&t<=0)return;let l=o.length-2;l>=0&&t<=0&&t==o[l+1]?o[l]+=e:e==0&&o[l]==0?o[l+1]+=t:n?(o[l]+=e,o[l+1]+=t):o.push(e,t)}function st(o,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<o.length)o[o.length-1]=o[o.length-1].append(t);else{for(;o.length<n;)o.push(ie.empty);o.push(t)}}function kn(o,e,t){let n=o.inserted;for(let l=0,s=0,a=0;a<o.sections.length;){let r=o.sections[a++],d=o.sections[a++];if(d<0)l+=r,s+=r;else{let h=l,f=s,c=ie.empty;for(;h+=r,f+=d,d&&n&&(c=c.append(n[a-2>>1])),!(t||a==o.sections.length||o.sections[a+1]<0);)r=o.sections[a++],d=o.sections[a++];e(l,h,s,f,c),l=h,s=f}}}function bn(o,e,t,n=!1){let l=[],s=n?[]:null,a=new Ht(o),r=new Ht(e);for(let d=-1;;)if(a.ins==-1&&r.ins==-1){let h=Math.min(a.len,r.len);we(l,h,-1),a.forward(h),r.forward(h)}else if(r.ins>=0&&(a.ins<0||d==a.i||a.off==0&&(r.len<a.len||r.len==a.len&&!t))){let h=r.len;for(we(l,r.ins,-1);h;){let f=Math.min(a.len,h);a.ins>=0&&d<a.i&&a.len<=f&&(we(l,0,a.ins),s&&st(s,l,a.text),d=a.i),a.forward(f),h-=f}r.next()}else if(a.ins>=0){let h=0,f=a.len;for(;f;)if(r.ins==-1){let c=Math.min(f,r.len);h+=c,f-=c,r.forward(c)}else if(r.ins==0&&r.len<f)f-=r.len,r.next();else break;we(l,h,d<a.i?a.ins:0),s&&d<a.i&&st(s,l,a.text),d=a.i,a.forward(a.len-f)}else{if(a.done&&r.done)return s?me.createSet(l,s):Ye.create(l);throw new Error("Mismatched change set lengths")}}function ts(o,e,t=!1){let n=[],l=t?[]:null,s=new Ht(o),a=new Ht(e);for(let r=!1;;){if(s.done&&a.done)return l?me.createSet(n,l):Ye.create(n);if(s.ins==0)we(n,s.len,0,r),s.next();else if(a.len==0&&!a.done)we(n,0,a.ins,r),l&&st(l,n,a.text),a.next();else{if(s.done||a.done)throw new Error("Mismatched change set lengths");{let d=Math.min(s.len2,a.len),h=n.length;if(s.ins==-1){let f=a.ins==-1?-1:a.off?0:a.ins;we(n,d,f,r),l&&f&&st(l,n,a.text)}else a.ins==-1?(we(n,s.off?0:s.len,d,r),l&&st(l,n,s.textBit(d))):(we(n,s.off?0:s.len,a.off?0:a.ins,r),l&&!a.off&&st(l,n,a.text));r=(s.ins>d||a.ins>=0&&a.len>d)&&(r||n.length>h),s.forward2(d),a.forward(d)}}}}class Ht{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ie.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ie.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class mt{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,l;return this.empty?n=l=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),n==this.from&&l==this.to?this:new mt(n,l,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return H.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return H.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return H.range(e.anchor,e.head)}static create(e,t,n){return new mt(e,t,n)}}class H{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:H.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new H([this.main],0)}addRange(e,t=!0){return H.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,H.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new H(e.ranges.map(t=>mt.fromJSON(t)),e.main)}static single(e,t=e){return new H([H.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,l=0;l<e.length;l++){let s=e[l];if(s.empty?s.from<=n:s.from<n)return H.normalized(e.slice(),t);n=s.to}return new H(e,t)}static cursor(e,t=0,n,l){return mt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(l??16777215)<<6)}static range(e,t,n,l){let s=(n??16777215)<<6|(l==null?7:Math.min(6,l));return t<e?mt.create(t,e,48|s):mt.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((l,s)=>l.from-s.from),t=e.indexOf(n);for(let l=1;l<e.length;l++){let s=e[l],a=e[l-1];if(s.empty?s.from<=a.to:s.from<a.to){let r=a.from,d=Math.max(s.to,a.to);l<=t&&t--,e.splice(--l,2,s.anchor>s.head?H.range(d,r):H.range(r,d))}}return new H(e,t)}}function is(o,e){for(let t of o.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let yn=0;class Y{constructor(e,t,n,l,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=l,this.id=yn++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Y(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:wn),!!e.static,e.enables)}of(e){return new Si([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Si(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Si(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function wn(o,e){return o==e||o.length==e.length&&o.every((t,n)=>t===e[n])}class Si{constructor(e,t,n,l){this.dependencies=e,this.facet=t,this.type=n,this.value=l,this.id=yn++}dynamicSlot(e){var t;let n=this.value,l=this.facet.compareInput,s=this.id,a=e[s]>>1,r=this.type==2,d=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?d=!0:c=="selection"?h=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||f.push(e[c.id]);return{create(c){return c.values[a]=n(c),1},update(c,u){if(d&&u.docChanged||h&&(u.docChanged||u.selection)||xn(c,f)){let m=n(c);if(r?!ns(m,c.values[a],l):!l(m,c.values[a]))return c.values[a]=m,1}return 0},reconfigure:(c,u)=>{let m,b=u.config.address[s];if(b!=null){let y=Oi(u,b);if(this.dependencies.every(k=>k instanceof Y?u.facet(k)===c.facet(k):k instanceof gt?u.field(k,!1)==c.field(k,!1):!0)||(r?ns(m=n(c),y,l):l(m=n(c),y)))return c.values[a]=y,0}else m=n(c);return c.values[a]=m,1}}}}function ns(o,e,t){if(o.length!=e.length)return!1;for(let n=0;n<o.length;n++)if(!t(o[n],e[n]))return!1;return!0}function xn(o,e){let t=!1;for(let n of e)Qt(o,n)&1&&(t=!0);return t}function zd(o,e,t){let n=t.map(d=>o[d.id]),l=t.map(d=>d.type),s=n.filter(d=>!(d&1)),a=o[e.id]>>1;function r(d){let h=[];for(let f=0;f<n.length;f++){let c=Oi(d,n[f]);if(l[f]==2)for(let u of c)h.push(u);else h.push(c)}return e.combine(h)}return{create(d){for(let h of n)Qt(d,h);return d.values[a]=r(d),1},update(d,h){if(!xn(d,s))return 0;let f=r(d);return e.compare(f,d.values[a])?0:(d.values[a]=f,1)},reconfigure(d,h){let f=xn(d,n),c=h.config.facets[e.id],u=h.facet(e);if(c&&!f&&wn(t,c))return d.values[a]=u,0;let m=r(d);return e.compare(m,u)?(d.values[a]=u,0):(d.values[a]=m,1)}}}const ls=Y.define({static:!0});class gt{constructor(e,t,n,l,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=l,this.spec=s,this.provides=void 0}static define(e){let t=new gt(yn++,e.create,e.update,e.compare||((n,l)=>n===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ls).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,l)=>{let s=n.values[t],a=this.updateF(s,l);return this.compareF(s,a)?0:(n.values[t]=a,1)},reconfigure:(n,l)=>l.config.address[this.id]!=null?(n.values[t]=l.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,ls.of({field:this,create:e})]}get extension(){return this}}const kt={lowest:4,low:3,default:2,high:1,highest:0};function Kt(o){return e=>new ss(e,o)}const qd={highest:Kt(kt.highest),high:Kt(kt.high),default:Kt(kt.default),low:Kt(kt.low),lowest:Kt(kt.lowest)};class ss{constructor(e,t){this.inner=e,this.prec=t}}class Ni{of(e){return new vn(this,e)}reconfigure(e){return Ni.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class vn{constructor(e,t){this.compartment=e,this.inner=t}}class Bi{constructor(e,t,n,l,s,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=l,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let l=[],s=Object.create(null),a=new Map;for(let u of Ud(e,t,a))u instanceof gt?l.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let r=Object.create(null),d=[],h=[];for(let u of l)r[u.id]=h.length<<1,h.push(m=>u.slot(m));let f=n?.config.facets;for(let u in s){let m=s[u],b=m[0].facet,y=f&&f[u]||[];if(m.every(k=>k.type==0))if(r[b.id]=d.length<<1|1,wn(y,m))d.push(n.facet(b));else{let k=b.combine(m.map(v=>v.value));d.push(n&&b.compare(k,n.facet(b))?n.facet(b):k)}else{for(let k of m)k.type==0?(r[k.id]=d.length<<1|1,d.push(k.value)):(r[k.id]=h.length<<1,h.push(v=>k.dynamicSlot(v)));r[b.id]=h.length<<1,h.push(k=>zd(k,b,m))}}let c=h.map(u=>u(r));return new Bi(e,a,c,r,d,s)}}function Ud(o,e,t){let n=[[],[],[],[],[]],l=new Map;function s(a,r){let d=l.get(a);if(d!=null){if(d<=r)return;let h=n[d].indexOf(a);h>-1&&n[d].splice(h,1),a instanceof vn&&t.delete(a.compartment)}if(l.set(a,r),Array.isArray(a))for(let h of a)s(h,r);else if(a instanceof vn){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(a.compartment)||a.inner;t.set(a.compartment,h),s(h,r)}else if(a instanceof ss)s(a.inner,a.prec);else if(a instanceof gt)n[r].push(a),a.provides&&s(a.provides,r);else if(a instanceof Si)n[r].push(a),a.facet.extensions&&s(a.facet.extensions,kt.default);else{let h=a.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,r)}}return s(o,kt.default),n.reduce((a,r)=>a.concat(r))}function Qt(o,e){if(e&1)return 2;let t=e>>1,n=o.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;o.status[t]=4;let l=o.computeSlot(o,o.config.dynamicSlots[t]);return o.status[t]=2|l}function Oi(o,e){return e&1?o.config.staticValues[e>>1]:o.values[e>>1]}const os=Y.define(),Cn=Y.define({combine:o=>o.some(e=>e),static:!0}),as=Y.define({combine:o=>o.length?o[0]:void 0,static:!0}),rs=Y.define(),ds=Y.define(),cs=Y.define(),hs=Y.define({combine:o=>o.length?o[0]:!1});class Nt{constructor(e,t){this.type=e,this.value=t}static define(){return new Wd}}class Wd{of(e){return new Nt(this,e)}}class Hd{constructor(e){this.map=e}of(e){return new ue(this,e)}}class ue{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ue(this.type,t)}is(e){return this.type==e}static define(e={}){return new Hd(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let l of e){let s=l.map(t);s&&n.push(s)}return n}}ue.reconfigure=ue.define(),ue.appendConfig=ue.define();class xe{constructor(e,t,n,l,s,a){this.startState=e,this.changes=t,this.selection=n,this.effects=l,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,n&&is(n,t.newLength),s.some(r=>r.type==xe.time)||(this.annotations=s.concat(xe.time.of(Date.now())))}static create(e,t,n,l,s,a){return new xe(e,t,n,l,s,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(xe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}xe.time=Nt.define(),xe.userEvent=Nt.define(),xe.addToHistory=Nt.define(),xe.remote=Nt.define();function Kd(o,e){let t=[];for(let n=0,l=0;;){let s,a;if(n<o.length&&(l==e.length||e[l]>=o[n]))s=o[n++],a=o[n++];else if(l<e.length)s=e[l++],a=e[l++];else return t;!t.length||t[t.length-1]<s?t.push(s,a):t[t.length-1]<a&&(t[t.length-1]=a)}}function fs(o,e,t){var n;let l,s,a;return t?(l=e.changes,s=me.empty(e.changes.length),a=o.changes.compose(e.changes)):(l=e.changes.map(o.changes),s=o.changes.mapDesc(e.changes,!0),a=o.changes.compose(l)),{changes:a,selection:e.selection?e.selection.map(s):(n=o.selection)===null||n===void 0?void 0:n.map(l),effects:ue.mapEffects(o.effects,l).concat(ue.mapEffects(e.effects,s)),annotations:o.annotations.length?o.annotations.concat(e.annotations):e.annotations,scrollIntoView:o.scrollIntoView||e.scrollIntoView}}function Sn(o,e,t){let n=e.selection,l=Bt(e.annotations);return e.userEvent&&(l=l.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,o.facet(as)),selection:n&&(n instanceof H?n:H.single(n.anchor,n.head)),effects:Bt(e.effects),annotations:l,scrollIntoView:!!e.scrollIntoView}}function us(o,e,t){let n=Sn(o,e.length?e[0]:{},o.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let a=!!e[s].sequential;n=fs(n,Sn(o,e[s],a?n.changes.newLength:o.doc.length),a)}let l=xe.create(o,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Gd(t?Qd(l):l)}function Qd(o){let e=o.startState,t=!0;for(let l of e.facet(rs)){let s=l(o);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Kd(t,s))}if(t!==!0){let l,s;if(t===!1)s=o.changes.invertedDesc,l=me.empty(e.doc.length);else{let a=o.changes.filter(t);l=a.changes,s=a.filtered.mapDesc(a.changes).invertedDesc}o=xe.create(e,l,o.selection&&o.selection.map(s),ue.mapEffects(o.effects,s),o.annotations,o.scrollIntoView)}let n=e.facet(ds);for(let l=n.length-1;l>=0;l--){let s=n[l](o);s instanceof xe?o=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?o=s[0]:o=us(e,Bt(s),!1)}return o}function Gd(o){let e=o.startState,t=e.facet(cs),n=o;for(let l=t.length-1;l>=0;l--){let s=t[l](o);s&&Object.keys(s).length&&(n=fs(n,Sn(e,s,o.changes.newLength),!0))}return n==o?o:xe.create(e,o.changes,o.selection,n.effects,n.annotations,n.scrollIntoView)}const Yd=[];function Bt(o){return o==null?Yd:Array.isArray(o)?o:[o]}var Xe=function(o){return o[o.Word=0]="Word",o[o.Space=1]="Space",o[o.Other=2]="Other",o}(Xe||(Xe={}));const Xd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Nn;try{Nn=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Jd(o){if(Nn)return Nn.test(o);for(let e=0;e<o.length;e++){let t=o[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Xd.test(t)))return!0}return!1}function Zd(o){return e=>{if(!/\S/.test(e))return Xe.Space;if(Jd(e))return Xe.Word;for(let t=0;t<o.length;t++)if(e.indexOf(o[t])>-1)return Xe.Word;return Xe.Other}}class se{constructor(e,t,n,l,s,a){this.config=e,this.doc=t,this.selection=n,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let r=0;r<this.config.dynamicSlots.length;r++)Qt(this,r<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Qt(this,n),Oi(this,n)}update(...e){return us(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:l}=t;for(let r of e.effects)r.is(Ni.reconfigure)?(t&&(l=new Map,t.compartments.forEach((d,h)=>l.set(h,d)),t=null),l.set(r.value.compartment,r.value.extension)):r.is(ue.reconfigure)?(t=null,n=r.value):r.is(ue.appendConfig)&&(t=null,n=Bt(n).concat(r.value));let s;t?s=e.startState.values.slice():(t=Bi.resolve(n,l,this),s=new se(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(d,h)=>h.reconfigure(d,this),null).values);let a=e.startState.facet(Cn)?e.newSelection:e.newSelection.asSingle();new se(t,e.newDoc,a,s,(r,d)=>d.update(r,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:H.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),l=this.changes(n.changes),s=[n.range],a=Bt(n.effects);for(let r=1;r<t.ranges.length;r++){let d=e(t.ranges[r]),h=this.changes(d.changes),f=h.map(l);for(let u=0;u<r;u++)s[u]=s[u].map(f);let c=l.mapDesc(h,!0);s.push(d.range.map(c)),l=l.compose(f),a=ue.mapEffects(a,f).concat(ue.mapEffects(Bt(d.effects),c))}return{changes:l,selection:H.create(s,t.mainIndex),effects:a}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(se.lineSeparator))}toText(e){return ie.of(e.split(this.facet(se.lineSeparator)||gn))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Qt(this,t),Oi(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let l=e[n];l instanceof gt&&this.config.address[l.id]!=null&&(t[n]=l.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let l=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let a=n[s],r=e[s];l.push(a.init(d=>a.spec.fromJSON(r,d)))}}return se.create({doc:e.doc,selection:H.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=Bi.resolve(e.extensions||[],new Map),n=e.doc instanceof ie?e.doc:ie.of((e.doc||"").split(t.staticFacet(se.lineSeparator)||gn)),l=e.selection?e.selection instanceof H?e.selection:H.single(e.selection.anchor,e.selection.head):H.single(0);return is(l,n.length),t.staticFacet(Cn)||(l=l.asSingle()),new se(t,n,l,t.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(se.tabSize)}get lineBreak(){return this.facet(se.lineSeparator)||`
5
- `}get readOnly(){return this.facet(hs)}phrase(e,...t){for(let n of this.facet(se.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,l)=>{if(l=="$")return"$";let s=+(l||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let l=[];for(let s of this.facet(os))for(let a of s(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&l.push(a[e]);return l}charCategorizer(e){return Zd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:l}=this.doc.lineAt(e),s=this.charCategorizer(e),a=e-n,r=e-n;for(;a>0;){let d=Ge(t,a,!1);if(s(t.slice(d,a))!=Xe.Word)break;a=d}for(;r<l;){let d=Ge(t,r);if(s(t.slice(r,d))!=Xe.Word)break;r=d}return a==r?null:H.range(a+n,r+n)}}se.allowMultipleSelections=Cn,se.tabSize=Y.define({combine:o=>o.length?o[0]:4}),se.lineSeparator=as,se.readOnly=hs,se.phrases=Y.define({compare(o,e){let t=Object.keys(o),n=Object.keys(e);return t.length==n.length&&t.every(l=>o[l]==e[l])}}),se.languageData=os,se.changeFilter=rs,se.transactionFilter=ds,se.transactionExtender=cs,Ni.reconfigure=ue.define();class Ot{eq(e){return this==e}range(e,t=e){return Gt.create(e,t,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=Ve.TrackDel;class Gt{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Gt(e,t,n)}}function Bn(o,e){return o.from-e.from||o.value.startSide-e.value.startSide}class On{constructor(e,t,n,l){this.from=e,this.to=t,this.value=n,this.maxPoint=l}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,l=0){let s=n?this.to:this.from;for(let a=l,r=s.length;;){if(a==r)return a;let d=a+r>>1,h=s[d]-e||(n?this.value[d].endSide:this.value[d].startSide)-t;if(d==a)return h>=0?a:r;h>=0?r=d:a=d+1}}between(e,t,n,l){for(let s=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,s);s<a;s++)if(l(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],l=[],s=[],a=-1,r=-1;for(let d=0;d<this.value.length;d++){let h=this.value[d],f=this.from[d]+e,c=this.to[d]+e,u,m;if(f==c){let b=t.mapPos(f,h.startSide,h.mapMode);if(b==null||(u=m=b,h.startSide!=h.endSide&&(m=t.mapPos(f,h.endSide),m<u)))continue}else if(u=t.mapPos(f,h.startSide),m=t.mapPos(c,h.endSide),u>m||u==m&&h.startSide>0&&h.endSide<=0)continue;(m-u||h.endSide-h.startSide)<0||(a<0&&(a=u),h.point&&(r=Math.max(r,m-u)),n.push(h),l.push(u-a),s.push(m-a))}return{mapped:n.length?new On(l,s,n,r):null,pos:a}}}class re{constructor(e,t,n,l){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=l}static create(e,t,n,l){return new re(e,t,n,l)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:l=0,filterTo:s=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(n&&(t=t.slice().sort(Bn)),this.isEmpty)return t.length?re.of(t):this;let r=new ms(this,null,-1).goto(0),d=0,h=[],f=new Vi;for(;r.value||d<t.length;)if(d<t.length&&(r.from-t[d].from||r.startSide-t[d].value.startSide)>=0){let c=t[d++];f.addInner(c.from,c.to,c.value)||h.push(c)}else r.rangeIndex==1&&r.chunkIndex<this.chunk.length&&(d==t.length||this.chunkEnd(r.chunkIndex)<t[d].from)&&(!a||l>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&f.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!a||l>r.to||s<r.from||a(r.from,r.to,r.value))&&(f.addInner(r.from,r.to,r.value)||h.push(Gt.create(r.from,r.to,r.value))),r.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?re.empty:this.nextLayer.update({add:h,filter:a,filterFrom:l,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],l=-1;for(let a=0;a<this.chunk.length;a++){let r=this.chunkPos[a],d=this.chunk[a],h=e.touchesRange(r,r+d.length);if(h===!1)l=Math.max(l,d.maxPoint),t.push(d),n.push(e.mapPos(r));else if(h===!0){let{mapped:f,pos:c}=d.map(r,e);f&&(l=Math.max(l,f.maxPoint),t.push(f),n.push(c))}}let s=this.nextLayer.map(e);return t.length==0?s:new re(n,t,s||re.empty,l)}between(e,t,n){if(!this.isEmpty){for(let l=0;l<this.chunk.length;l++){let s=this.chunkPos[l],a=this.chunk[l];if(t>=s&&e<=s+a.length&&a.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Yt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Yt.from(e).goto(t)}static compare(e,t,n,l,s=-1){let a=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),r=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),d=ps(a,r,n),h=new Xt(a,d,s),f=new Xt(r,d,s);n.iterGaps((c,u,m)=>gs(h,c,f,u,m,l)),n.empty&&n.length==0&&gs(h,0,f,0,0,l)}static eq(e,t,n=0,l){l==null&&(l=999999999);let s=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),a=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(s.length!=a.length)return!1;if(!s.length)return!0;let r=ps(s,a),d=new Xt(s,r,0).goto(n),h=new Xt(a,r,0).goto(n);for(;;){if(d.to!=h.to||!_n(d.active,h.active)||d.point&&(!h.point||!d.point.eq(h.point)))return!1;if(d.to>l)return!0;d.next(),h.next()}}static spans(e,t,n,l,s=-1){let a=new Xt(e,null,s).goto(t),r=t,d=a.openStart;for(;;){let h=Math.min(a.to,n);if(a.point){let f=a.activeForPoint(a.to),c=a.pointFrom<t?f.length+1:a.point.startSide<0?f.length:Math.min(f.length,d);l.point(r,h,a.point,f,c,a.pointRank),d=Math.min(a.openEnd(h),f.length)}else h>r&&(l.span(r,h,a.active,d),d=a.openEnd(h));if(a.to>n)return d+(a.point&&a.to>n?1:0);r=a.to,a.next()}}static of(e,t=!1){let n=new Vi;for(let l of e instanceof Gt?[e]:t?ec(e):e)n.add(l.from,l.to,l.value);return n.finish()}static join(e){if(!e.length)return re.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let l=e[n];l!=re.empty;l=l.nextLayer)t=new re(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}re.empty=new re([],[],null,-1);function ec(o){if(o.length>1)for(let e=o[0],t=1;t<o.length;t++){let n=o[t];if(Bn(e,n)>0)return o.slice().sort(Bn);e=n}return o}re.empty.nextLayer=re.empty;class Vi{finishChunk(e){this.chunks.push(new On(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Vi)).add(e,t,n)}addInner(e,t,n){let l=e-this.lastTo||n.startSide-this.last.endSide;if(l<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return l<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(re.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=re.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ps(o,e,t){let n=new Map;for(let s of o)for(let a=0;a<s.chunk.length;a++)s.chunk[a].maxPoint<=0&&n.set(s.chunk[a],s.chunkPos[a]);let l=new Set;for(let s of e)for(let a=0;a<s.chunk.length;a++){let r=n.get(s.chunk[a]);r!=null&&(t?t.mapPos(r):r)==s.chunkPos[a]&&!t?.touchesRange(r,r+s.chunk[a].length)&&l.add(s.chunk[a])}return l}class ms{constructor(e,t,n,l=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=l}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let l=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(l)||this.layer.chunkEnd(this.chunkIndex)<e||l.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let l=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<l)&&this.setRangeIndex(l)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Yt{constructor(e){this.heap=e}static from(e,t=null,n=-1){let l=[];for(let s=0;s<e.length;s++)for(let a=e[s];!a.isEmpty;a=a.nextLayer)a.maxPoint>=n&&l.push(new ms(a,t,n,s));return l.length==1?l[0]:new Yt(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Vn(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Vn(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Vn(this.heap,0)}}}function Vn(o,e){for(let t=o[e];;){let n=(e<<1)+1;if(n>=o.length)break;let l=o[n];if(n+1<o.length&&l.compare(o[n+1])>=0&&(l=o[n+1],n++),t.compare(l)<0)break;o[n]=t,o[e]=l,e=n}}class Xt{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Yt.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){_i(this.active,e),_i(this.activeTo,e),_i(this.activeRank,e),this.minActive=ks(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:l,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||l-this.activeTo[t])>0;)t++;Mi(this.active,t,n),Mi(this.activeTo,t,l),Mi(this.activeRank,t,s),e&&Mi(e,t,this.cursor.from),this.minActive=ks(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),n&&_i(n,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let l=n.length-1;l>=0&&n[l]<e;l--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function gs(o,e,t,n,l,s){o.goto(e),t.goto(n);let a=n+l,r=n,d=n-e;for(;;){let h=o.to+d-t.to||o.endSide-t.endSide,f=h<0?o.to+d:t.to,c=Math.min(f,a);if(o.point||t.point?o.point&&t.point&&(o.point==t.point||o.point.eq(t.point))&&_n(o.activeForPoint(o.to),t.activeForPoint(t.to))||s.comparePoint(r,c,o.point,t.point):c>r&&!_n(o.active,t.active)&&s.compareRange(r,c,o.active,t.active),f>a)break;r=f,h<=0&&o.next(),h>=0&&t.next()}}function _n(o,e){if(o.length!=e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!=e[t]&&!o[t].eq(e[t]))return!1;return!0}function _i(o,e){for(let t=e,n=o.length-1;t<n;t++)o[t]=o[t+1];o.pop()}function Mi(o,e,t){for(let n=o.length-1;n>=e;n--)o[n+1]=o[n];o[e]=t}function ks(o,e){let t=-1,n=1e9;for(let l=0;l<e.length;l++)(e[l]-n||o[l].endSide-o[t].endSide)<0&&(t=l,n=e[l]);return t}function tc(o,e,t,n){for(let l=0,s=0;;){if(s>=e)return l;if(l==o.length)break;s+=o.charCodeAt(l)==9?t-s%t:1,l=Ge(o,l)}return n===!0?-1:o.length}const Mn="ͼ",bs=typeof Symbol>"u"?"__"+Mn:Symbol.for(Mn),Tn=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ys=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ot{constructor(e,t){this.rules=[];let{finish:n}=t||{};function l(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function s(a,r,d,h){let f=[],c=/^@(\w+)\b/.exec(a[0]),u=c&&c[1]=="keyframes";if(c&&r==null)return d.push(a[0]+";");for(let m in r){let b=r[m];if(/&/.test(m))s(m.split(/,\s*/).map(y=>a.map(k=>y.replace(/&/,k))).reduce((y,k)=>y.concat(k)),b,d);else if(b&&typeof b=="object"){if(!c)throw new RangeError("The value of a property ("+m+") should be a primitive value.");s(l(m),b,f,u)}else b!=null&&f.push(m.replace(/_.*/,"").replace(/[A-Z]/g,y=>"-"+y.toLowerCase())+": "+b+";")}(f.length||u)&&d.push((n&&!c&&!h?a.map(n):a).join(", ")+" {"+f.join(" ")+"}")}for(let a in e)s(l(a),e[a],this.rules)}getRules(){return this.rules.join(`
6
- `)}static newName(){let e=ys[bs]||1;return ys[bs]=e+1,Mn+e.toString(36)}static mount(e,t,n){let l=e[Tn],s=n&&n.nonce;l?s&&l.setNonce(s):l=new ic(e,s),l.mount(Array.isArray(t)?t:[t],e)}}let ws=new Map;class ic{constructor(e,t){let n=e.ownerDocument||e,l=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let s=ws.get(n);if(s)return e[Tn]=s;this.sheet=new l.CSSStyleSheet,ws.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Tn]=this}mount(e,t){let n=this.sheet,l=0,s=0;for(let a=0;a<e.length;a++){let r=e[a],d=this.modules.indexOf(r);if(d<s&&d>-1&&(this.modules.splice(d,1),s--,d=-1),d==-1){if(this.modules.splice(s++,0,r),n)for(let h=0;h<r.rules.length;h++)n.insertRule(r.rules[h],l++)}else{for(;s<d;)l+=this.modules[s++].rules.length;l+=r.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let a="";for(let d=0;d<this.modules.length;d++)a+=this.modules[d].getRules()+`
7
- `;this.styleTag.textContent=a;let r=t.head||t;this.styleTag.parentNode!=r&&r.insertBefore(this.styleTag,r.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Vt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ke=0;ke<10;ke++)Vt[48+ke]=Vt[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Vt[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Vt[ke]=String.fromCharCode(ke+32),An[ke]=String.fromCharCode(ke);for(var En in Vt)An.hasOwnProperty(En)||(An[En]=Vt[En]);function Jt(o){let e;return o.nodeType==11?e=o.getSelection?o:o.ownerDocument:e=o,e.getSelection()}function In(o,e){return e?o==e||o.contains(e.nodeType!=1?e.parentNode:e):!1}function nc(o){let e=o.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ti(o,e){if(!e.anchorNode)return!1;try{return In(o,e.anchorNode)}catch{return!1}}function Zt(o){return o.nodeType==3?yt(o,0,o.nodeValue.length).getClientRects():o.nodeType==1?o.getClientRects():[]}function ei(o,e,t,n){return t?xs(o,e,t,n,-1)||xs(o,e,t,n,1):!1}function bt(o){for(var e=0;;e++)if(o=o.previousSibling,!o)return e}function Ai(o){return o.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(o.nodeName)}function xs(o,e,t,n,l){for(;;){if(o==t&&e==n)return!0;if(e==(l<0?0:Je(o))){if(o.nodeName=="DIV")return!1;let s=o.parentNode;if(!s||s.nodeType!=1)return!1;e=bt(o)+(l<0?0:1),o=s}else if(o.nodeType==1){if(o=o.childNodes[e+(l<0?-1:0)],o.nodeType==1&&o.contentEditable=="false")return!1;e=l<0?Je(o):0}else return!1}}function Je(o){return o.nodeType==3?o.nodeValue.length:o.childNodes.length}function Ei(o,e){let t=e?o.left:o.right;return{left:t,right:t,top:o.top,bottom:o.bottom}}function lc(o){let e=o.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:o.innerWidth,top:0,bottom:o.innerHeight}}function vs(o,e){let t=e.width/o.offsetWidth,n=e.height/o.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-o.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-o.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function sc(o,e,t,n,l,s,a,r){let d=o.ownerDocument,h=d.defaultView||window;for(let f=o,c=!1;f&&!c;)if(f.nodeType==1){let u,m=f==d.body,b=1,y=1;if(m)u=lc(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let w=f.getBoundingClientRect();({scaleX:b,scaleY:y}=vs(f,w)),u={left:w.left,right:w.left+f.clientWidth*b,top:w.top,bottom:w.top+f.clientHeight*y}}let k=0,v=0;if(l=="nearest")e.top<u.top?(v=-(u.top-e.top+a),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+a)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+a,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+a)));else{let w=e.bottom-e.top,O=u.bottom-u.top;v=(l=="center"&&w<=O?e.top+w/2-O/2:l=="start"||l=="center"&&t<0?e.top-a:e.bottom-O+a)-u.top}if(n=="nearest"?e.left<u.left?(k=-(u.left-e.left+s),t>0&&e.right>u.right+k&&(k=e.right-u.right+k+s)):e.right>u.right&&(k=e.right-u.right+s,t<0&&e.left<u.left+k&&(k=-(u.left+k-e.left+s))):k=(n=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:n=="start"==r?e.left-s:e.right-(u.right-u.left)+s)-u.left,k||v)if(m)h.scrollBy(k,v);else{let w=0,O=0;if(v){let g=f.scrollTop;f.scrollTop+=v/y,O=(f.scrollTop-g)*y}if(k){let g=f.scrollLeft;f.scrollLeft+=k/b,w=(f.scrollLeft-g)*b}e={left:e.left-w,top:e.top-O,right:e.right-w,bottom:e.bottom-O},w&&Math.abs(w-k)<1&&(n="nearest"),O&&Math.abs(O-v)<1&&(l="nearest")}if(m)break;f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function oc(o){let e=o.ownerDocument,t,n;for(let l=o.parentNode;l&&!(l==e.body||t&&n);)if(l.nodeType==1)!n&&l.scrollHeight>l.clientHeight&&(n=l),!t&&l.scrollWidth>l.clientWidth&&(t=l),l=l.assignedSlot||l.parentNode;else if(l.nodeType==11)l=l.host;else break;return{x:t,y:n}}class ac{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Je(t):0),n,Math.min(e.focusOffset,n?Je(n):0))}set(e,t,n,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=l}}let _t=null;function Cs(o){if(o.setActive)return o.setActive();if(_t)return o.focus(_t);let e=[];for(let t=o;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(o.focus(_t==null?{get preventScroll(){return _t={preventScroll:!0},!0}}:void 0),!_t){_t=!1;for(let t=0;t<e.length;){let n=e[t++],l=e[t++],s=e[t++];n.scrollTop!=l&&(n.scrollTop=l),n.scrollLeft!=s&&(n.scrollLeft=s)}}}let Ss;function yt(o,e,t=e){let n=Ss||(Ss=document.createRange());return n.setEnd(o,t),n.setStart(o,e),n}function Mt(o,e,t,n){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=n);let s=new KeyboardEvent("keydown",l);s.synthetic=!0,o.dispatchEvent(s);let a=new KeyboardEvent("keyup",l);return a.synthetic=!0,o.dispatchEvent(a),s.defaultPrevented||a.defaultPrevented}function rc(o){for(;o;){if(o&&(o.nodeType==9||o.nodeType==11&&o.host))return o;o=o.assignedSlot||o.parentNode}return null}function Ns(o){for(;o.attributes.length;)o.removeAttributeNode(o.attributes[0])}function dc(o,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Je(t));;)if(n){if(t.nodeType!=1)return!1;let l=t.childNodes[n-1];l.contentEditable=="false"?n--:(t=l,n=Je(t))}else{if(t==o)return!0;n=bt(t),t=t.parentNode}}function Bs(o){return o.scrollTop>Math.max(1,o.scrollHeight-o.clientHeight-4)}function Os(o,e){for(let t=o,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Je(t)}else if(t.parentNode&&!Ai(t))n=bt(t),t=t.parentNode;else return null}}function Vs(o,e){for(let t=o,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!Ai(t))n=bt(t)+1,t=t.parentNode;else return null}}class ve{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new ve(e.parentNode,bt(e),t)}static after(e,t){return new ve(e.parentNode,bt(e)+1,t)}}const Dn=[];class oe{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,l=null,s;for(let a of this.children){if(a.flags&7){if(!a.dom&&(s=l?l.nextSibling:n.firstChild)){let r=oe.get(s);(!r||!r.parent&&r.canReuseDOM(a))&&a.reuseDOM(s)}a.sync(e,t),a.flags&=-8}if(s=l?l.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=a.dom&&(t.written=!0),a.dom.parentNode==n)for(;s&&s!=a.dom;)s=_s(s);else n.insertBefore(a.dom,s);l=a.dom}for(s=l?l.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=_s(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let l=Je(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;l==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?l=-1:l=1),e=s}l<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!oe.get(n);)n=n.nextSibling;if(!n)return this.length;for(let l=0,s=0;;l++){let a=this.children[l];if(a.dom==n)return s;s+=a.length+a.breakAfter}}domBoundsAround(e,t,n=0){let l=-1,s=-1,a=-1,r=-1;for(let d=0,h=n,f=n;d<this.children.length;d++){let c=this.children[d],u=h+c.length;if(h<e&&u>t)return c.domBoundsAround(e,t,h);if(u>=e&&l==-1&&(l=d,s=h),h>t&&c.dom.parentNode==this.dom){a=d,r=f;break}f=u,h=u+c.breakAfter}return{from:s,to:r<0?n+this.length:r,startDOM:(l?this.children[l-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:a<this.children.length&&a>=0?this.children[a].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Dn){this.markDirty();for(let l=e;l<t;l++){let s=this.children[l];s.parent==this&&n.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...n);for(let l=0;l<n.length;l++)n[l].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Ms(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,l,s,a){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}oe.prototype.breakAfter=0;function _s(o){let e=o.nextSibling;return o.parentNode.removeChild(o),e}class Ms{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Ts(o,e,t,n,l,s,a,r,d){let{children:h}=o,f=h.length?h[e]:null,c=s.length?s[s.length-1]:null,u=c?c.breakAfter:a;if(!(e==n&&f&&!a&&!u&&s.length<2&&f.merge(t,l,s.length?c:null,t==0,r,d))){if(n<h.length){let m=h[n];m&&(l<m.length||m.breakAfter&&c?.breakAfter)?(e==n&&(m=m.split(l),l=0),!u&&c&&m.merge(0,l,c,!0,0,d)?s[s.length-1]=m:((l||m.children.length&&!m.children[0].length)&&m.merge(0,l,null,!1,0,d),s.push(m))):m?.breakAfter&&(c?c.breakAfter=1:a=1),n++}for(f&&(f.breakAfter=a,t>0&&(!a&&s.length&&f.merge(t,f.length,s[0],!1,r,0)?f.breakAfter=s.shift().breakAfter:(t<f.length||f.children.length&&f.children[f.children.length-1].length==0)&&f.merge(t,f.length,null,!1,r,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),d=s.length?0:r;else if(h[e].become(s[0]))e++,s.shift(),r=s.length?0:d;else break;!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,r,d)&&e--,(e<n||s.length)&&o.replaceChildren(e,n,s)}}function As(o,e,t,n,l,s){let a=o.childCursor(),{i:r,off:d}=a.findPos(t,1),{i:h,off:f}=a.findPos(e,-1),c=e-t;for(let u of n)c+=u.length;o.length+=c,Ts(o,h,f,r,d,n,0,l,s)}let Be=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Pn=typeof document<"u"?document:{documentElement:{style:{}}};const Fn=/Edge\/(\d+)/.exec(Be.userAgent),Es=/MSIE \d/.test(Be.userAgent),$n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Be.userAgent),Ii=!!(Es||$n||Fn),Is=!Ii&&/gecko\/(\d+)/i.test(Be.userAgent),Rn=!Ii&&/Chrome\/(\d+)/.exec(Be.userAgent),Ds="webkitFontSmoothing"in Pn.documentElement.style,Ps=!Ii&&/Apple Computer/.test(Be.vendor),Fs=Ps&&(/Mobile\/\w+/.test(Be.userAgent)||Be.maxTouchPoints>2);var W={mac:Fs||/Mac/.test(Be.platform),windows:/Win/.test(Be.platform),linux:/Linux|X11/.test(Be.platform),ie:Ii,ie_version:Es?Pn.documentMode||6:$n?+$n[1]:Fn?+Fn[1]:0,gecko:Is,gecko_version:Is?+(/Firefox\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,chrome:!!Rn,chrome_version:Rn?+Rn[1]:0,ios:Fs,android:/Android\b/.test(Be.userAgent),webkit:Ds,safari:Ps,webkit_version:Ds?+(/\bAppleWebKit\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,tabSize:Pn.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const cc=256;class De extends oe{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof De)||this.length-(t-e)+n.length>cc||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new De(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new ve(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return hc(this.dom,e,t)}}class Ze extends oe{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let l of t)l.setParent(this)}setAttrs(e){if(Ns(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,l,s,a){return n&&(!(n instanceof Ze&&n.mark.eq(this.mark))||e&&s<=0||t<this.length&&a<=0)?!1:(As(this,e,t,n?n.children.slice():[],s-1,a-1),this.markDirty(),!0)}split(e){let t=[],n=0,l=-1,s=0;for(let r of this.children){let d=n+r.length;d>e&&t.push(n<e?r.split(e-n):r),l<0&&n>=e&&(l=s),n=d,s++}let a=this.length-e;return this.length=e,l>-1&&(this.children.length=l,this.markDirty()),new Ze(this.mark,t,a)}domAtPos(e){return $s(this,e)}coordsAt(e,t){return Ls(this,e,t)}}function hc(o,e,t){let n=o.nodeValue.length;e>n&&(e=n);let l=e,s=e,a=0;e==0&&t<0||e==n&&t>=0?W.chrome||W.gecko||(e?(l--,a=1):s<n&&(s++,a=-1)):t<0?l--:s<n&&s++;let r=yt(o,l,s).getClientRects();if(!r.length)return null;let d=r[(a?a<0:t>=0)?0:r.length-1];return W.safari&&!a&&d.width==0&&(d=Array.prototype.find.call(r,h=>h.width)||d),a?Ei(d,a<0):d||null}class wt extends oe{static create(e,t,n){return new wt(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=wt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,l,s,a){return n&&(!(n instanceof wt)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&a<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof wt&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return ie.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,l=this.posAtStart;return n?n.slice(l,l+this.length):ie.empty}domAtPos(e){return(this.length?e==0:this.side>0)?ve.before(this.dom):ve.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let l=this.dom.getClientRects(),s=null;if(!l.length)return null;let a=this.side?this.side<0:e>0;for(let r=a?l.length-1:0;s=l[r],!(e>0?r==0:r==l.length-1||s.top<s.bottom);r+=a?-1:1);return Ei(s,!a)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Tt extends oe{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Tt&&e.side==this.side}split(){return new Tt(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?ve.before(this.dom):ve.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ie.empty}get isHidden(){return!0}}De.prototype.children=wt.prototype.children=Tt.prototype.children=Dn;function $s(o,e){let t=o.dom,{children:n}=o,l=0;for(let s=0;l<n.length;l++){let a=n[l],r=s+a.length;if(!(r==s&&a.getSide()<=0)){if(e>s&&e<r&&a.dom.parentNode==t)return a.domAtPos(e-s);if(e<=s)break;s=r}}for(let s=l;s>0;s--){let a=n[s-1];if(a.dom.parentNode==t)return a.domAtPos(a.length)}for(let s=l;s<n.length;s++){let a=n[s];if(a.dom.parentNode==t)return a.domAtPos(0)}return new ve(t,0)}function Rs(o,e,t){let n,{children:l}=o;t>0&&e instanceof Ze&&l.length&&(n=l[l.length-1])instanceof Ze&&n.mark.eq(e.mark)?Rs(n,e.children[0],t-1):(l.push(e),e.setParent(o)),o.length+=e.length}function Ls(o,e,t){let n=null,l=-1,s=null,a=-1;function r(h,f){for(let c=0,u=0;c<h.children.length&&u<=f;c++){let m=h.children[c],b=u+m.length;b>=f&&(m.children.length?r(m,f-u):(!s||s.isHidden&&t>0)&&(b>f||u==b&&m.getSide()>0)?(s=m,a=f-u):(u<f||u==b&&m.getSide()<0&&!m.isHidden)&&(n=m,l=f-u)),u=b}}r(o,e);let d=(t<0?n:s)||n||s;return d?d.coordsAt(Math.max(0,d==n?l:a),t):fc(o)}function fc(o){let e=o.dom.lastChild;if(!e)return o.dom.getBoundingClientRect();let t=Zt(e);return t[t.length-1]||null}function Ln(o,e){for(let t in o)t=="class"&&e.class?e.class+=" "+o.class:t=="style"&&e.style?e.style+=";"+o.style:e[t]=o[t];return e}const js=Object.create(null);function Di(o,e,t){if(o==e)return!0;o||(o=js),e||(e=js);let n=Object.keys(o),l=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=l.length-(t&&l.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(l.indexOf(s)==-1||o[s]!==e[s]))return!1;return!0}function jn(o,e,t){let n=!1;if(e)for(let l in e)t&&l in t||(n=!0,l=="style"?o.style.cssText="":o.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(n=!0,l=="style"?o.style.cssText=t[l]:o.setAttribute(l,t[l]));return n}function uc(o){let e=Object.create(null);for(let t=0;t<o.attributes.length;t++){let n=o.attributes[t];e[n.name]=n.value}return e}class zn{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ze=function(o){return o[o.Text=0]="Text",o[o.WidgetBefore=1]="WidgetBefore",o[o.WidgetAfter=2]="WidgetAfter",o[o.WidgetRange=3]="WidgetRange",o}(ze||(ze={}));class Ce extends Ot{constructor(e,t,n,l){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=l}get heightRelevant(){return!1}static mark(e){return new ti(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new at(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,l;if(e.isBlockGap)n=-5e8,l=4e8;else{let{start:s,end:a}=zs(e,t);n=(s?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new at(e,n,l,t,e.widget||null,!0)}static line(e){return new ii(e)}static set(e,t=!1){return re.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ce.none=re.empty;class ti extends Ce{constructor(e){let{start:t,end:n}=zs(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ti&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&Di(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ti.prototype.point=!1;class ii extends Ce{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ii&&this.spec.class==e.spec.class&&Di(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ii.prototype.mapMode=Ve.TrackBefore,ii.prototype.point=!0;class at extends Ce{constructor(e,t,n,l,s,a){super(t,n,s,e),this.block=l,this.isReplace=a,this.mapMode=l?t<=0?Ve.TrackBefore:Ve.TrackAfter:Ve.TrackDel}get type(){return this.startSide!=this.endSide?ze.WidgetRange:this.startSide<=0?ze.WidgetBefore:ze.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof at&&pc(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}at.prototype.point=!0;function zs(o,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=o;return t==null&&(t=o.inclusive),n==null&&(n=o.inclusive),{start:t??e,end:n??e}}function pc(o,e){return o==e||!!(o&&e&&o.compare(e))}function qn(o,e,t,n=0){let l=t.length-1;l>=0&&t[l]+n>=o?t[l]=Math.max(t[l],e):t.push(o,e)}class fe extends oe{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,l,s,a){if(n){if(!(n instanceof fe))return!1;this.dom||n.transferDOM(this)}return l&&this.setDeco(n?n.attrs:null),As(this,e,t,n?n.children.slice():[],s,a),!0}split(e){let t=new fe;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:l}=this.childPos(e);l&&(t.append(this.children[n].split(l),0),this.children[n].merge(l,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)t.append(this.children[s],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Di(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Rs(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Ln(t,this.attrs||{})),n&&(this.attrs=Ln({class:n},this.attrs||{}))}domAtPos(e){return $s(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Ns(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(jn(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let l=this.dom.lastChild;for(;l&&oe.get(l)instanceof Ze;)l=l.lastChild;if(!l||!this.length||l.nodeName!="BR"&&((n=oe.get(l))===null||n===void 0?void 0:n.isEditable)==!1&&(!W.ios||!this.children.some(s=>s instanceof De))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof De)||/[^ -~]/.test(n.text))return null;let l=Zt(n.dom);if(l.length!=1)return null;e+=l[0].width,t=l[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=Ls(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:l}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-l.lineHeight)<2&&l.textHeight<s){let a=(s-l.textHeight)/2;return{top:n.top+a,bottom:n.bottom-a,left:n.left,right:n.left}}}return n}become(e){return e instanceof fe&&this.children.length==0&&e.children.length==0&&Di(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,l=0;n<e.children.length;n++){let s=e.children[n],a=l+s.length;if(a>=t){if(s instanceof fe)return s;if(a>t)break}l=a+s.breakAfter}return null}}class et extends oe{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,l,s,a){return n&&(!(n instanceof et)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&a<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?ve.before(this.dom):ve.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new et(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Dn}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):ie.empty}domBoundsAround(){return null}become(e){return e instanceof et&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof Un?null:Ei(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}}class Un extends zn{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class ni{constructor(e,t,n,l){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=l,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof et&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new fe),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Pi(new Tt(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof et)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:r}=this.cursor.next(this.skip);if(this.skip=0,r)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let l=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Pi(new De(this.text.slice(this.textOff,this.textOff+l)),t),n),this.atCursorPos=!0,this.textOff+=l,e-=l,n=0}}span(e,t,n,l){this.buildText(t-e,n,l),this.pos=t,this.openStart<0&&(this.openStart=l)}point(e,t,n,l,s,a){if(this.disallowBlockEffectsFor[a]&&n instanceof at){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=t-e;if(n instanceof at)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new et(n.widget||At.block,r,n));else{let d=wt.create(n.widget||At.inline,r,r?0:n.startSide),h=this.atCursorPos&&!d.isEditable&&s<=l.length&&(e<t||n.startSide>0),f=!d.isEditable&&(e<t||s>l.length||n.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!h&&!d.isEditable&&(this.pendingBuffer=0),this.flushBuffer(l),h&&(c.append(Pi(new Tt(1),l),s),s=l.length+Math.max(0,s-l.length)),c.append(Pi(d,l),s),this.atCursorPos=f,this.pendingBuffer=f?e<t||s>l.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=l.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,l,s){let a=new ni(e,t,n,s);return a.openEnd=re.spans(l,t,n,a),a.openStart<0&&(a.openStart=a.openEnd),a.finish(a.openEnd),a}}function Pi(o,e){for(let t of e)o=new Ze(t,[o],o.length);return o}class At extends zn{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}At.inline=new At("span"),At.block=new At("div");var be=function(o){return o[o.LTR=0]="LTR",o[o.RTL=1]="RTL",o}(be||(be={}));const xt=be.LTR,Wn=be.RTL;function qs(o){let e=[];for(let t=0;t<o.length;t++)e.push(1<<+o[t]);return e}const mc=qs("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),gc=qs("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Hn=Object.create(null),qe=[];for(let o of["()","[]","{}"]){let e=o.charCodeAt(0),t=o.charCodeAt(1);Hn[e]=t,Hn[t]=-e}function Us(o){return o<=247?mc[o]:1424<=o&&o<=1524?2:1536<=o&&o<=1785?gc[o-1536]:1774<=o&&o<=2220?4:8192<=o&&o<=8204?256:64336<=o&&o<=65023?4:1}const kc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class rt{get dir(){return this.level%2?Wn:xt}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,l){let s=-1;for(let a=0;a<e.length;a++){let r=e[a];if(r.from<=t&&r.to>=t){if(r.level==n)return a;(s<0||(l!=0?l<0?r.from<t:r.to>t:e[s].level>r.level))&&(s=a)}}if(s<0)throw new RangeError("Index out of range");return s}}function Ws(o,e){if(o.length!=e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],l=e[t];if(n.from!=l.from||n.to!=l.to||n.direction!=l.direction||!Ws(n.inner,l.inner))return!1}return!0}const ae=[];function bc(o,e,t,n,l){for(let s=0;s<=n.length;s++){let a=s?n[s-1].to:e,r=s<n.length?n[s].from:t,d=s?256:l;for(let h=a,f=d,c=d;h<r;h++){let u=Us(o.charCodeAt(h));u==512?u=f:u==8&&c==4&&(u=16),ae[h]=u==4?2:u,u&7&&(c=u),f=u}for(let h=a,f=d,c=d;h<r;h++){let u=ae[h];if(u==128)h<r-1&&f==ae[h+1]&&f&24?u=ae[h]=f:ae[h]=256;else if(u==64){let m=h+1;for(;m<r&&ae[m]==64;)m++;let b=h&&f==8||m<t&&ae[m]==8?c==1?1:8:256;for(let y=h;y<m;y++)ae[y]=b;h=m-1}else u==8&&c==1&&(ae[h]=1);f=u,u&7&&(c=u)}}}function yc(o,e,t,n,l){let s=l==1?2:1;for(let a=0,r=0,d=0;a<=n.length;a++){let h=a?n[a-1].to:e,f=a<n.length?n[a].from:t;for(let c=h,u,m,b;c<f;c++)if(m=Hn[u=o.charCodeAt(c)])if(m<0){for(let y=r-3;y>=0;y-=3)if(qe[y+1]==-m){let k=qe[y+2],v=k&2?l:k&4?k&1?s:l:0;v&&(ae[c]=ae[qe[y]]=v),r=y;break}}else{if(qe.length==189)break;qe[r++]=c,qe[r++]=u,qe[r++]=d}else if((b=ae[c])==2||b==1){let y=b==l;d=y?0:1;for(let k=r-3;k>=0;k-=3){let v=qe[k+2];if(v&2)break;if(y)qe[k+2]|=2;else{if(v&4)break;qe[k+2]|=4}}}}}function wc(o,e,t,n){for(let l=0,s=n;l<=t.length;l++){let a=l?t[l-1].to:o,r=l<t.length?t[l].from:e;for(let d=a;d<r;){let h=ae[d];if(h==256){let f=d+1;for(;;)if(f==r){if(l==t.length)break;f=t[l++].to,r=l<t.length?t[l].from:e}else if(ae[f]==256)f++;else break;let c=s==1,u=(f<e?ae[f]:n)==1,m=c==u?c?1:2:n;for(let b=f,y=l,k=y?t[y-1].to:o;b>d;)b==k&&(b=t[--y].from,k=y?t[y-1].to:o),ae[--b]=m;d=f}else s=h,d++}}}function Kn(o,e,t,n,l,s,a){let r=n%2?2:1;if(n%2==l%2)for(let d=e,h=0;d<t;){let f=!0,c=!1;if(h==s.length||d<s[h].from){let y=ae[d];y!=r&&(f=!1,c=y==16)}let u=!f&&r==1?[]:null,m=f?n:n+1,b=d;e:for(;;)if(h<s.length&&b==s[h].from){if(c)break e;let y=s[h];if(!f)for(let k=y.to,v=h+1;;){if(k==t)break e;if(v<s.length&&s[v].from==k)k=s[v++].to;else{if(ae[k]==r)break e;break}}if(h++,u)u.push(y);else{y.from>d&&a.push(new rt(d,y.from,m));let k=y.direction==xt!=!(m%2);Qn(o,k?n+1:n,l,y.inner,y.from,y.to,a),d=y.to}b=y.to}else{if(b==t||(f?ae[b]!=r:ae[b]==r))break;b++}u?Kn(o,d,b,n+1,l,u,a):d<b&&a.push(new rt(d,b,m)),d=b}else for(let d=t,h=s.length;d>e;){let f=!0,c=!1;if(!h||d>s[h-1].to){let y=ae[d-1];y!=r&&(f=!1,c=y==16)}let u=!f&&r==1?[]:null,m=f?n:n+1,b=d;e:for(;;)if(h&&b==s[h-1].to){if(c)break e;let y=s[--h];if(!f)for(let k=y.from,v=h;;){if(k==e)break e;if(v&&s[v-1].to==k)k=s[--v].from;else{if(ae[k-1]==r)break e;break}}if(u)u.push(y);else{y.to<d&&a.push(new rt(y.to,d,m));let k=y.direction==xt!=!(m%2);Qn(o,k?n+1:n,l,y.inner,y.from,y.to,a),d=y.from}b=y.from}else{if(b==e||(f?ae[b-1]!=r:ae[b-1]==r))break;b--}u?Kn(o,b,d,n+1,l,u,a):b<d&&a.push(new rt(b,d,m)),d=b}}function Qn(o,e,t,n,l,s,a){let r=e%2?2:1;bc(o,l,s,n,r),yc(o,l,s,n,r),wc(l,s,n,r),Kn(o,l,s,e,t,n,a)}function xc(o,e,t){if(!o)return[new rt(0,0,e==Wn?1:0)];if(e==xt&&!t.length&&!kc.test(o))return Hs(o.length);if(t.length)for(;o.length>ae.length;)ae[ae.length]=256;let n=[],l=e==xt?0:1;return Qn(o,l,l,t,0,o.length,n),n}function Hs(o){return[new rt(0,o,0)]}let Ks="";function vc(o,e,t,n,l){var s;let a=n.head-o.from,r=rt.find(e,a,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),d=e[r],h=d.side(l,t);if(a==h){let u=r+=l?1:-1;if(u<0||u>=e.length)return null;d=e[r=u],a=d.side(!l,t),h=d.side(l,t)}let f=Ge(o.text,a,d.forward(l,t));(f<d.from||f>d.to)&&(f=h),Ks=o.text.slice(Math.min(a,f),Math.max(a,f));let c=r==(l?e.length-1:0)?null:e[r+(l?1:-1)];return c&&f==h&&c.level+(l?0:1)<d.level?H.cursor(c.side(!l,t)+o.from,c.forward(l,t)?1:-1,c.level):H.cursor(f+o.from,d.forward(l,t)?-1:1,d.level)}function Cc(o,e,t){for(let n=e;n<t;n++){let l=Us(o.charCodeAt(n));if(l==1)return xt;if(l==2||l==4)return Wn}return xt}const Qs=Y.define(),Gs=Y.define(),Ys=Y.define(),Xs=Y.define(),Gn=Y.define(),Js=Y.define(),Zs=Y.define(),Yn=Y.define(),Xn=Y.define(),eo=Y.define({combine:o=>o.some(e=>e)}),Sc=Y.define({combine:o=>o.some(e=>e)}),to=Y.define();class Et{constructor(e,t="nearest",n="nearest",l=5,s=5,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=l,this.xMargin=s,this.isSnapshot=a}map(e){return e.empty?this:new Et(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Et(H.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Fi=ue.define({map:(o,e)=>o.map(e)}),io=ue.define();function Ue(o,e,t){let n=o.facet(Xs);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const dt=Y.define({combine:o=>o.length?o[0]:!0});let Nc=0;const li=Y.define();class It{constructor(e,t,n,l,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=l,this.extension=s(this)}static define(e,t){const{eventHandlers:n,eventObservers:l,provide:s,decorations:a}=t||{};return new It(Nc++,e,n,l,r=>{let d=[li.of(r)];return a&&d.push(si.of(h=>{let f=h.plugin(r);return f?a(f):Ce.none})),s&&d.push(s(r)),d})}static fromClass(e,t){return It.define(n=>new e(n),t)}}class Jn{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ue(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ue(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ue(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const no=Y.define(),Zn=Y.define(),si=Y.define(),lo=Y.define(),el=Y.define(),so=Y.define();function oo(o,e){let t=o.state.facet(so);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(o):s),l=[];return re.spans(n,e.from,e.to,{point(){},span(s,a,r,d){let h=s-e.from,f=a-e.from,c=l;for(let u=r.length-1;u>=0;u--,d--){let m=r[u].spec.bidiIsolate,b;if(m==null&&(m=Cc(e.text,h,f)),d>0&&c.length&&(b=c[c.length-1]).to==h&&b.direction==m)b.to=f,c=b.inner;else{let y={from:h,to:f,direction:m,inner:[]};c.push(y),c=y.inner}}}}),l}const ao=Y.define();function ro(o){let e=0,t=0,n=0,l=0;for(let s of o.state.facet(ao)){let a=s(o);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(t=Math.max(t,a.right)),a.top!=null&&(n=Math.max(n,a.top)),a.bottom!=null&&(l=Math.max(l,a.bottom)))}return{left:e,right:t,top:n,bottom:l}}const oi=Y.define();class Ae{constructor(e,t,n,l){this.fromA=e,this.toA=t,this.fromB=n,this.toB=l}join(e){return new Ae(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let l=e[t-1];if(!(l.fromA>n.toA)){if(l.toA<n.fromA)break;n=n.join(l),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let l=0,s=0,a=0,r=0;;l++){let d=l==e.length?null:e[l],h=a-r,f=d?d.fromB:1e9;for(;s<t.length&&t[s]<f;){let c=t[s],u=t[s+1],m=Math.max(r,c),b=Math.min(f,u);if(m<=b&&new Ae(m+h,b+h,m,b).addToSet(n),u>f)break;s+=2}if(!d)return n;new Ae(d.fromA,d.toA,d.fromB,d.toB).addToSet(n),a=d.toA,r=d.toB}}}class $i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=me.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let l=[];this.changes.iterChangedRanges((s,a,r,d)=>l.push(new Ae(s,a,r,d))),this.changedRanges=l}static create(e,t,n){return new $i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class co extends oe{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Ce.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new fe],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ae(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:f})=>f<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!Ac(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let s=l>-1?Oc(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;n=new Ae(h,f,e.changes.mapPos(h,-1),e.changes.mapPos(f,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(W.ie||W.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,r=this.updateDeco(),d=Mc(a,r,e.changes);return n=Ae.extendWithRanges(n,d),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:l}=this.view;l.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=W.chrome||W.ios?{node:l.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,a),this.flags&=-8,a&&(a.written||l.selectionRange.focusNode!=a.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(a=>a.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let a of this.children)a instanceof et&&a.widget instanceof Un&&s.push(a.dom);l.updateGaps(s)}updateChildren(e,t,n){let l=n?n.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let a=l.length-1;;a--){let r=a>=0?l[a]:null;if(!r)break;let{fromA:d,toA:h,fromB:f,toB:c}=r,u,m,b,y;if(n&&n.range.fromB<c&&n.range.toB>f){let g=ni.build(this.view.state.doc,f,n.range.fromB,this.decorations,this.dynamicDecorationMap),p=ni.build(this.view.state.doc,n.range.toB,c,this.decorations,this.dynamicDecorationMap);m=g.breakAtStart,b=g.openStart,y=p.openEnd;let N=this.compositionView(n);p.breakAtStart?N.breakAfter=1:p.content.length&&N.merge(N.length,N.length,p.content[0],!1,p.openStart,0)&&(N.breakAfter=p.content[0].breakAfter,p.content.shift()),g.content.length&&N.merge(0,0,g.content[g.content.length-1],!0,0,g.openEnd)&&g.content.pop(),u=g.content.concat(N).concat(p.content)}else({content:u,breakAtStart:m,openStart:b,openEnd:y}=ni.build(this.view.state.doc,f,c,this.decorations,this.dynamicDecorationMap));let{i:k,off:v}=s.findPos(h,1),{i:w,off:O}=s.findPos(d,-1);Ts(this,w,O,k,v,u,m,b,y)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(io)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new De(e.text.nodeValue);t.flags|=8;for(let{deco:l}of e.marks)t=new Ze(l,[t],t.length);let n=new fe;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,a)=>{a.flags|=8|(a.children.some(d=>d.flags&7)?1:0),this.markedForComposition.add(a);let r=oe.get(s);r&&r!=a&&(r.dom=null),a.setDOM(s)},n=this.childPos(e.range.fromB,1),l=this.children[n.i];t(e.line,l);for(let s=e.marks.length-1;s>=-1;s--)n=l.childPos(n.off,1),l=l.children[n.i],t(s>=0?e.marks[s].node:e.text,l)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,l=n==this.dom,s=!l&&Ti(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(l||t||s))return;let a=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,d=this.moveToLine(this.domAtPos(r.anchor)),h=r.empty?d:this.moveToLine(this.domAtPos(r.head));if(W.gecko&&r.empty&&!this.hasComposition&&Bc(d)){let c=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(c,d.node.childNodes[d.offset]||null)),d=h=new ve(c,0),a=!0}let f=this.view.observer.selectionRange;(a||!f.focusNode||(!ei(d.node,d.offset,f.anchorNode,f.anchorOffset)||!ei(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,r))&&(this.view.observer.ignore(()=>{W.android&&W.chrome&&this.dom.contains(f.focusNode)&&Tc(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=Jt(this.view.root);if(c)if(r.empty){if(W.gecko){let u=Vc(d.node,d.offset);if(u&&u!=3){let m=(u==1?Os:Vs)(d.node,d.offset);m&&(d=new ve(m.node,m.offset))}}c.collapse(d.node,d.offset),r.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=r.bidiLevel)}else if(c.extend){c.collapse(d.node,d.offset);try{c.extend(h.node,h.offset)}catch{}}else{let u=document.createRange();r.anchor>r.head&&([d,h]=[h,d]),u.setEnd(h.node,h.offset),u.setStart(d.node,d.offset),c.removeAllRanges(),c.addRange(u)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(d,h)),this.impreciseAnchor=d.precise?null:new ve(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new ve(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ei(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Jt(e.root),{anchorNode:l,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=fe.find(this,t.head);if(!a)return;let r=a.posAtStart;if(t.head==r||t.head==r+a.length)return;let d=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!d||!h||d.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc);n.collapse(f.node,f.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(l,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let l=e.offset;!n&&l<t.childNodes.length;l++){let s=oe.get(t.childNodes[l]);s instanceof fe&&(n=s.domAtPos(0))}for(let l=e.offset-1;!n&&l>=0;l--){let s=oe.get(t.childNodes[l]);s instanceof fe&&(n=s.domAtPos(s.length))}return n?new ve(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=oe.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let l=this.children[t];if(n<l.length||l instanceof fe)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,l=0;for(let s=this.length,a=this.children.length-1;a>=0;a--){let r=this.children[a],d=s-r.breakAfter,h=d-r.length;if(d<e)break;if(h<=e&&(h<e||r.covers(-1))&&(d>e||r.covers(1))&&(!n||r instanceof fe&&!(n instanceof fe&&t>=0)))n=r,l=h;else if(n&&h==e&&d==e&&r instanceof et&&Math.abs(t)<2){if(r.deco.startSide<0)break;a&&(n=null)}s=h}return n?n.coordsAt(e-l,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),l=this.children[t];if(!(l instanceof fe))return null;for(;l.children.length;){let{i:r,off:d}=l.childPos(n,1);for(;;r++){if(r==l.children.length)return null;if((l=l.children[r]).length)break}n=d}if(!(l instanceof De))return null;let s=Ge(l.text,n);if(s==n)return null;let a=yt(l.dom,n,s).getClientRects();for(let r=0;r<a.length;r++){let d=a[r];if(r==a.length-1||d.top<d.bottom&&d.left<d.right)return d}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:l}=e,s=this.view.contentDOM.clientWidth,a=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,d=this.view.textDirection==be.LTR;for(let h=0,f=0;f<this.children.length;f++){let c=this.children[f],u=h+c.length;if(u>l)break;if(h>=n){let m=c.dom.getBoundingClientRect();if(t.push(m.height),a){let b=c.dom.lastChild,y=b?Zt(b):[];if(y.length){let k=y[y.length-1],v=d?k.right-m.left:m.right-k.left;v>r&&(r=v,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?be.RTL:be.LTR}measureTextSize(){for(let s of this.children)if(s instanceof fe){let a=s.measureTextSize();if(a)return a}let e=document.createElement("div"),t,n,l;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Zt(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,l=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:l}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Ms(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,l=0;;l++){let s=l==t.viewports.length?null:t.viewports[l],a=s?s.from-1:this.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Ce.replace({widget:new Un(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!s)break;n=s.to+1}return Ce.set(e)}updateDeco(){let e=1,t=this.view.state.facet(si).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,l=this.view.state.facet(lo).map((s,a)=>{let r=typeof s=="function";return r&&(n=!0),r?s(this.view):s});for(l.length&&(this.dynamicDecorationMap[e++]=n,t.push(re.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(to))try{if(h(this.view,e.range,e))return!0}catch(f){Ue(this.view.state,f,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),l;if(!n)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,l.left),top:Math.min(n.top,l.top),right:Math.max(n.right,l.right),bottom:Math.max(n.bottom,l.bottom)});let s=ro(this.view),a={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:d}=this.view.scrollDOM;sc(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,r),-r),Math.max(Math.min(e.yMargin,d),-d),this.view.textDirection==be.LTR)}}function Bc(o){return o.node.nodeType==1&&o.node.firstChild&&(o.offset==0||o.node.childNodes[o.offset-1].contentEditable=="false")&&(o.offset==o.node.childNodes.length||o.node.childNodes[o.offset].contentEditable=="false")}function ho(o,e){let t=o.observer.selectionRange;if(!t.focusNode)return null;let n=Os(t.focusNode,t.focusOffset),l=Vs(t.focusNode,t.focusOffset),s=n||l;if(l&&n&&l.node!=n.node){let r=oe.get(l.node);if(!r||r instanceof De&&r.text!=l.node.nodeValue)s=l;else if(o.docView.lastCompositionAfterCursor){let d=oe.get(n.node);!d||d instanceof De&&d.text!=n.node.nodeValue||(s=l)}}if(o.docView.lastCompositionAfterCursor=s!=n,!s)return null;let a=e-s.offset;return{from:a,to:a+s.node.nodeValue.length,node:s.node}}function Oc(o,e,t){let n=ho(o,t);if(!n)return null;let{node:l,from:s,to:a}=n,r=l.nodeValue;if(/[\n\r]/.test(r)||o.state.doc.sliceString(n.from,n.to)!=r)return null;let d=e.invertedDesc,h=new Ae(d.mapPos(s),d.mapPos(a),s,a),f=[];for(let c=l.parentNode;;c=c.parentNode){let u=oe.get(c);if(u instanceof Ze)f.push({node:c,deco:u.mark});else{if(u instanceof fe||c.nodeName=="DIV"&&c.parentNode==o.contentDOM)return{range:h,text:l,marks:f,line:c};if(c!=o.contentDOM)f.push({node:c,deco:new ti({inclusive:!0,attributes:uc(c),tagName:c.tagName.toLowerCase()})});else return null}}}function Vc(o,e){return o.nodeType!=1?0:(e&&o.childNodes[e-1].contentEditable=="false"?1:0)|(e<o.childNodes.length&&o.childNodes[e].contentEditable=="false"?2:0)}let _c=class{constructor(){this.changes=[]}compareRange(e,t){qn(e,t,this.changes)}comparePoint(e,t){qn(e,t,this.changes)}};function Mc(o,e,t){let n=new _c;return re.compare(o,e,t,n),n.changes}function Tc(o,e){for(let t=o;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ac(o,e){let t=!1;return e&&o.iterChangedRanges((n,l)=>{n<e.to&&l>e.from&&(t=!0)}),t}function Ec(o,e,t=1){let n=o.charCategorizer(e),l=o.doc.lineAt(e),s=e-l.from;if(l.length==0)return H.cursor(e);s==0?t=1:s==l.length&&(t=-1);let a=s,r=s;t<0?a=Ge(l.text,s,!1):r=Ge(l.text,s);let d=n(l.text.slice(a,r));for(;a>0;){let h=Ge(l.text,a,!1);if(n(l.text.slice(h,a))!=d)break;a=h}for(;r<l.length;){let h=Ge(l.text,r);if(n(l.text.slice(r,h))!=d)break;r=h}return H.range(a+l.from,r+l.from)}function Ic(o,e){return e.left>o?e.left-o:Math.max(0,o-e.right)}function Dc(o,e){return e.top>o?e.top-o:Math.max(0,o-e.bottom)}function tl(o,e){return o.top<e.bottom-1&&o.bottom>e.top+1}function fo(o,e){return e<o.top?{top:e,left:o.left,right:o.right,bottom:o.bottom}:o}function uo(o,e){return e>o.bottom?{top:o.top,left:o.left,right:o.right,bottom:e}:o}function il(o,e,t){let n,l,s,a,r=!1,d,h,f,c;for(let b=o.firstChild;b;b=b.nextSibling){let y=Zt(b);for(let k=0;k<y.length;k++){let v=y[k];l&&tl(l,v)&&(v=fo(uo(v,l.bottom),l.top));let w=Ic(e,v),O=Dc(t,v);if(w==0&&O==0)return b.nodeType==3?po(b,e,t):il(b,e,t);if(!n||a>O||a==O&&s>w){n=b,l=v,s=w,a=O;let g=O?t<v.top?-1:1:w?e<v.left?-1:1:0;r=!g||(g>0?k<y.length-1:k>0)}w==0?t>v.bottom&&(!f||f.bottom<v.bottom)?(d=b,f=v):t<v.top&&(!c||c.top>v.top)&&(h=b,c=v):f&&tl(f,v)?f=uo(f,v.bottom):c&&tl(c,v)&&(c=fo(c,v.top))}}if(f&&f.bottom>=t?(n=d,l=f):c&&c.top<=t&&(n=h,l=c),!n)return{node:o,offset:0};let u=Math.max(l.left,Math.min(l.right,e));if(n.nodeType==3)return po(n,u,t);if(r&&n.contentEditable!="false")return il(n,u,t);let m=Array.prototype.indexOf.call(o.childNodes,n)+(e>=(l.left+l.right)/2?1:0);return{node:o,offset:m}}function po(o,e,t){let n=o.nodeValue.length,l=-1,s=1e9,a=0;for(let r=0;r<n;r++){let d=yt(o,r,r+1).getClientRects();for(let h=0;h<d.length;h++){let f=d[h];if(f.top==f.bottom)continue;a||(a=e-f.left);let c=(f.top>t?f.top-t:t-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&c<s){let u=e>=(f.left+f.right)/2,m=u;if((W.chrome||W.gecko)&&yt(o,r).getBoundingClientRect().left==f.right&&(m=!u),c<=0)return{node:o,offset:r+(m?1:0)};l=r+(m?1:0),s=c}}}return{node:o,offset:l>-1?l:a>0?o.nodeValue.length:0}}function mo(o,e,t,n=-1){var l,s;let a=o.contentDOM.getBoundingClientRect(),r=a.top+o.viewState.paddingTop,d,{docHeight:h}=o.viewState,{x:f,y:c}=e,u=c-r;if(u<0)return 0;if(u>h)return o.state.doc.length;for(let g=o.viewState.heightOracle.textHeight/2,p=!1;d=o.elementAtHeight(u),d.type!=ze.Text;)for(;u=n>0?d.bottom+g:d.top-g,!(u>=0&&u<=h);){if(p)return t?null:0;p=!0,n=-n}c=r+u;let m=d.from;if(m<o.viewport.from)return o.viewport.from==0?0:t?null:go(o,a,d,f,c);if(m>o.viewport.to)return o.viewport.to==o.state.doc.length?o.state.doc.length:t?null:go(o,a,d,f,c);let b=o.dom.ownerDocument,y=o.root.elementFromPoint?o.root:b,k=y.elementFromPoint(f,c);k&&!o.contentDOM.contains(k)&&(k=null),k||(f=Math.max(a.left+1,Math.min(a.right-1,f)),k=y.elementFromPoint(f,c),k&&!o.contentDOM.contains(k)&&(k=null));let v,w=-1;if(k&&((l=o.docView.nearest(k))===null||l===void 0?void 0:l.isEditable)!=!1){if(b.caretPositionFromPoint){let g=b.caretPositionFromPoint(f,c);g&&({offsetNode:v,offset:w}=g)}else if(b.caretRangeFromPoint){let g=b.caretRangeFromPoint(f,c);g&&({startContainer:v,startOffset:w}=g,(!o.contentDOM.contains(v)||W.safari&&Pc(v,w,f)||W.chrome&&Fc(v,w,f))&&(v=void 0))}}if(!v||!o.docView.dom.contains(v)){let g=fe.find(o.docView,m);if(!g)return u>d.top+d.height/2?d.to:d.from;({node:v,offset:w}=il(g.dom,f,c))}let O=o.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let g=O.dom.getBoundingClientRect();return e.y<g.top||e.y<=g.bottom&&e.x<=(g.left+g.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,w)+O.posAtStart}function go(o,e,t,n,l){let s=Math.round((n-e.left)*o.defaultCharacterWidth);if(o.lineWrapping&&t.height>o.defaultLineHeight*1.5){let r=o.viewState.heightOracle.textHeight,d=Math.floor((l-t.top-(o.defaultLineHeight-r)*.5)/r);s+=d*o.viewState.heightOracle.lineLength}let a=o.state.sliceDoc(t.from,t.to);return t.from+tc(a,s,o.state.tabSize)}function Pc(o,e,t){let n;if(o.nodeType!=3||e!=(n=o.nodeValue.length))return!1;for(let l=o.nextSibling;l;l=l.nextSibling)if(l.nodeType!=1||l.nodeName!="BR")return!1;return yt(o,n-1,n).getBoundingClientRect().left>t}function Fc(o,e,t){if(e!=0)return!1;for(let l=o;;){let s=l.parentNode;if(!s||s.nodeType!=1||s.firstChild!=l)return!1;if(s.classList.contains("cm-line"))break;l=s}let n=o.nodeType==1?o.getBoundingClientRect():yt(o,0,Math.max(o.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function $c(o,e){let t=o.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==ze.Text))return n}return t}function Rc(o,e,t,n){let l=$c(o,e.head),s=!n||l.type!=ze.Text||!(o.lineWrapping||l.widgetLineBreaks)?null:o.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(s){let a=o.dom.getBoundingClientRect(),r=o.textDirectionAt(l.from),d=o.posAtCoords({x:t==(r==be.LTR)?a.right-1:a.left+1,y:(s.top+s.bottom)/2});if(d!=null)return H.cursor(d,t?-1:1)}return H.cursor(t?l.to:l.from,t?-1:1)}function ko(o,e,t,n){let l=o.state.doc.lineAt(e.head),s=o.bidiSpans(l),a=o.textDirectionAt(l.from);for(let r=e,d=null;;){let h=vc(l,s,a,r,t),f=Ks;if(!h){if(l.number==(t?o.state.doc.lines:1))return r;f=`
8
- `,l=o.state.doc.line(l.number+(t?1:-1)),s=o.bidiSpans(l),h=o.visualLineSide(l,!t)}if(d){if(!d(f))return r}else{if(!n)return h;d=n(f)}r=h}}function Lc(o,e,t){let n=o.state.charCategorizer(e),l=n(t);return s=>{let a=n(s);return l==Xe.Space&&(l=a),l==a}}function jc(o,e,t,n){let l=e.head,s=t?1:-1;if(l==(t?o.state.doc.length:0))return H.cursor(l,e.assoc);let a=e.goalColumn,r,d=o.contentDOM.getBoundingClientRect(),h=o.coordsAtPos(l,e.assoc||-1),f=o.documentTop;if(h)a==null&&(a=h.left-d.left),r=s<0?h.top:h.bottom;else{let m=o.viewState.lineBlockAt(l);a==null&&(a=Math.min(d.right-d.left,o.defaultCharacterWidth*(l-m.from))),r=(s<0?m.top:m.bottom)+f}let c=d.left+a,u=n??o.viewState.heightOracle.textHeight>>1;for(let m=0;;m+=10){let b=r+(u+m)*s,y=mo(o,{x:c,y:b},!1,s);if(b<d.top||b>d.bottom||(s<0?y<l:y>l)){let k=o.docView.coordsForChar(y),v=!k||b<k.top?-1:1;return H.cursor(y,v,void 0,a)}}}function Ri(o,e,t){for(;;){let n=0;for(let l of o)l.between(e-1,e+1,(s,a,r)=>{if(e>s&&e<a){let d=n||t||(e-s<a-e?-1:1);e=d<0?s:a,n=d}});if(!n)return e}}function nl(o,e,t){let n=Ri(o.state.facet(el).map(l=>l(o)),t.from,e.head>t.from?-1:1);return n==t.from?t:H.cursor(n,n<t.from?1:-1)}const ai="￿";class zc{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ai}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let l=e;;){this.findPointBefore(n,l);let s=this.text.length;this.readNode(l);let a=l.nextSibling;if(a==t)break;let r=oe.get(l),d=oe.get(a);(r&&d?r.breakAfter:(r?r.breakAfter:Ai(l))||Ai(a)&&(l.nodeName!="BR"||l.cmIgnore)&&this.text.length>s)&&this.lineBreak(),l=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,a=1,r;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(r=l.exec(t))&&(s=r.index,a=r[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),a>1)for(let d of this.points)d.node==e&&d.pos>this.text.length&&(d.pos-=a-1);n=s+a}}readNode(e){if(e.cmIgnore)return;let t=oe.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let l=n.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(qc(e,n.node,n.offset)?t:0))}}function qc(o,e,t){for(;;){if(!e||t<Je(e))return!1;if(e==o)return!0;t=bt(e)+1,e=e.parentNode}}class bo{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Uc{constructor(e,t,n,l){this.typeOver=l,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:a}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let r=s||a?[]:Kc(e),d=new zc(r,e.state);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=Qc(r,this.bounds.from)}else{let r=e.observer.selectionRange,d=s&&s.node==r.focusNode&&s.offset==r.focusOffset||!In(e.contentDOM,r.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(r.focusNode,r.focusOffset),h=a&&a.node==r.anchorNode&&a.offset==r.anchorOffset||!In(e.contentDOM,r.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(r.anchorNode,r.anchorOffset),f=e.viewport;if((W.ios||W.chrome)&&e.state.selection.main.empty&&d!=h&&(f.from>0||f.to<e.state.doc.length)){let c=Math.min(d,h),u=Math.max(d,h),m=f.from-c,b=f.to-u;(m==0||m==1||c==0)&&(b==0||b==-1||u==e.state.doc.length)&&(d=0,h=e.state.doc.length)}this.newSel=H.single(h,d)}}}function yo(o,e){let t,{newSel:n}=e,l=o.state.selection.main,s=o.inputState.lastKeyTime>Date.now()-100?o.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:r}=e.bounds,d=l.from,h=null;(s===8||W.android&&e.text.length<r-a)&&(d=l.to,h="end");let f=Hc(o.state.doc.sliceString(a,r,ai),e.text,d-a,h);f&&(W.chrome&&s==13&&f.toB==f.from+2&&e.text.slice(f.from,f.toB)==ai+ai&&f.toB--,t={from:a+f.from,to:a+f.toA,insert:ie.of(e.text.slice(f.from,f.toB).split(ai))})}else n&&(!o.hasFocus&&o.state.facet(dt)||n.main.eq(l))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!l.empty&&n&&n.main.empty?t={from:l.from,to:l.to,insert:o.state.doc.slice(l.from,l.to)}:t&&t.from>=l.from&&t.to<=l.to&&(t.from!=l.from||t.to!=l.to)&&l.to-l.from-(t.to-t.from)<=4?t={from:l.from,to:l.to,insert:o.state.doc.slice(l.from,t.from).append(t.insert).append(o.state.doc.slice(t.to,l.to))}:(W.mac||W.android)&&t&&t.from==t.to&&t.from==l.head-1&&/^\. ?$/.test(t.insert.toString())&&o.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=H.single(n.main.anchor-1,n.main.head-1)),t={from:l.from,to:l.to,insert:ie.of([" "])}):W.chrome&&t&&t.from==t.to&&t.from==l.head&&t.insert.toString()==`
9
- `&&o.lineWrapping&&(n&&(n=H.single(n.main.anchor-1,n.main.head-1)),t={from:l.from,to:l.to,insert:ie.of([" "])}),t)return ll(o,t,n,s);if(n&&!n.main.eq(l)){let a=!1,r="select";return o.inputState.lastSelectionTime>Date.now()-50&&(o.inputState.lastSelectionOrigin=="select"&&(a=!0),r=o.inputState.lastSelectionOrigin),o.dispatch({selection:n,scrollIntoView:a,userEvent:r}),!0}else return!1}function ll(o,e,t,n=-1){if(W.ios&&o.inputState.flushIOSKey(e))return!0;let l=o.state.selection.main;if(W.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&o.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Mt(o.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>l.head)&&Mt(o.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&Mt(o.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();o.inputState.composing>=0&&o.inputState.composing++;let a,r=()=>a||(a=Wc(o,e,t));return o.state.facet(Js).some(d=>d(o,e.from,e.to,s,r))||o.dispatch(r()),!0}function Wc(o,e,t){let n,l=o.state,s=l.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&o.inputState.composing<0){let r=s.from<e.from?l.sliceDoc(s.from,e.from):"",d=s.to>e.to?l.sliceDoc(e.to,s.to):"";n=l.replaceSelection(o.state.toText(r+e.insert.sliceString(0,void 0,o.state.lineBreak)+d))}else{let r=l.changes(e),d=t&&t.main.to<=r.newLength?t.main:void 0;if(l.selection.ranges.length>1&&o.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=o.state.sliceDoc(e.from,e.to),f,c=t&&ho(o,t.main.head);if(c){let b=e.insert.length-(e.to-e.from);f={from:c.from,to:c.to-b}}else f=o.state.doc.lineAt(s.head);let u=s.to-e.to,m=s.to-s.from;n=l.changeByRange(b=>{if(b.from==s.from&&b.to==s.to)return{changes:r,range:d||b.map(r)};let y=b.to-u,k=y-h.length;if(b.to-b.from!=m||o.state.sliceDoc(k,y)!=h||b.to>=f.from&&b.from<=f.to)return{range:b};let v=l.changes({from:k,to:y,insert:e.insert}),w=b.to-s.to;return{changes:v,range:d?H.range(Math.max(0,d.anchor+w),Math.max(0,d.head+w)):b.map(v)}})}else n={changes:r,selection:d&&l.selection.replaceRange(d)}}let a="input.type";return(o.composing||o.inputState.compositionPendingChange&&o.inputState.compositionEndedAt>Date.now()-50)&&(o.inputState.compositionPendingChange=!1,a+=".compose",o.inputState.compositionFirstChange&&(a+=".start",o.inputState.compositionFirstChange=!1)),l.update(n,{userEvent:a,scrollIntoView:!0})}function Hc(o,e,t,n){let l=Math.min(o.length,e.length),s=0;for(;s<l&&o.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==l&&o.length==e.length)return null;let a=o.length,r=e.length;for(;a>0&&r>0&&o.charCodeAt(a-1)==e.charCodeAt(r-1);)a--,r--;if(n=="end"){let d=Math.max(0,s-Math.min(a,r));t-=a+d-s}if(a<s&&o.length<e.length){let d=t<=s&&t>=a?s-t:0;s-=d,r=s+(r-a),a=s}else if(r<s){let d=t<=s&&t>=r?s-t:0;s-=d,a=s+(a-r),r=s}return{from:s,toA:a,toB:r}}function Kc(o){let e=[];if(o.root.activeElement!=o.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:l,focusOffset:s}=o.observer.selectionRange;return t&&(e.push(new bo(t,n)),(l!=t||s!=n)&&e.push(new bo(l,s))),e}function Qc(o,e){if(o.length==0)return null;let t=o[0].pos,n=o.length==2?o[1].pos:t;return t>-1&&n>-1?H.single(t+e,n+e):null}class Gc{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,W.safari&&e.contentDOM.addEventListener("input",()=>null),W.gecko&&fh(e.contentDOM.ownerDocument)}handleEvent(e){!lh(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let l of n.observers)l(this.view,t);for(let l of n.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Yc(e),n=this.handlers,l=this.view.contentDOM;for(let s in t)if(s!="scroll"){let a=!t[s].handlers.length,r=n[s];r&&a!=!r.handlers.length&&(l.removeEventListener(s,this.handleEvent),r=null),r||l.addEventListener(s,this.handleEvent,{passive:a})}for(let s in n)s!="scroll"&&!t[s]&&l.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Jc.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),W.android&&W.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return W.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=xo.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Xc.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Mt(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:W.safari&&!W.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function wo(o,e){return(t,n)=>{try{return e.call(o,n,t)}catch(l){Ue(t.state,l)}}}function Yc(o){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of o){let l=n.spec;if(l&&l.domEventHandlers)for(let s in l.domEventHandlers){let a=l.domEventHandlers[s];a&&t(s).handlers.push(wo(n.value,a))}if(l&&l.domEventObservers)for(let s in l.domEventObservers){let a=l.domEventObservers[s];a&&t(s).observers.push(wo(n.value,a))}}for(let n in Pe)t(n).handlers.push(Pe[n]);for(let n in Ee)t(n).observers.push(Ee[n]);return e}const xo=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Xc="dthko",Jc=[16,17,18,20,91,92,224,225],Li=6;function ji(o){return Math.max(0,o)*.7+8}function Zc(o,e){return Math.max(Math.abs(o.clientX-e.clientX),Math.abs(o.clientY-e.clientY))}class eh{constructor(e,t,n,l){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=oc(e.contentDOM),this.atoms=e.state.facet(el).map(a=>a(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(se.allowMultipleSelections)&&th(e,t),this.dragging=nh(e,t)&&Mo(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Zc(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,l=0,s=0,a=this.view.win.innerWidth,r=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:r}=this.scrollParents.y.getBoundingClientRect());let d=ro(this.view);e.clientX-d.left<=l+Li?t=-ji(l-e.clientX):e.clientX+d.right>=a-Li&&(t=ji(e.clientX-a)),e.clientY-d.top<=s+Li?n=-ji(s-e.clientY):e.clientY+d.bottom>=r-Li&&(n=ji(e.clientY-r)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let l=e.ranges[n],s=null;if(l.empty){let a=Ri(this.atoms,l.from,0);a!=l.from&&(s=H.cursor(a,-1))}else{let a=Ri(this.atoms,l.from,-1),r=Ri(this.atoms,l.to,1);(a!=l.from||r!=l.to)&&(s=H.range(l.from==l.anchor?a:r,l.from==l.head?a:r))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?H.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function th(o,e){let t=o.state.facet(Qs);return t.length?t[0](e):W.mac?e.metaKey:e.ctrlKey}function ih(o,e){let t=o.state.facet(Gs);return t.length?t[0](e):W.mac?!e.altKey:!e.ctrlKey}function nh(o,e){let{main:t}=o.state.selection;if(t.empty)return!1;let n=Jt(o.root);if(!n||n.rangeCount==0)return!0;let l=n.getRangeAt(0).getClientRects();for(let s=0;s<l.length;s++){let a=l[s];if(a.left<=e.clientX&&a.right>=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function lh(o,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=o.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=oe.get(t))&&n.ignoreEvent(e))return!1;return!0}const Pe=Object.create(null),Ee=Object.create(null),vo=W.ie&&W.ie_version<15||W.ios&&W.webkit_version<604;function sh(o){let e=o.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{o.focus(),t.remove(),Co(o,t.value)},50)}function zi(o,e,t){for(let n of o.facet(e))t=n(t,o);return t}function Co(o,e){e=zi(o.state,Yn,e);let{state:t}=o,n,l=1,s=t.toText(e),a=s.lines==t.selection.ranges.length;if(sl!=null&&t.selection.ranges.every(d=>d.empty)&&sl==s.toString()){let d=-1;n=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==d)return{range:h};d=f.from;let c=t.toText((a?s.line(l++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:H.cursor(h.from+c.length)}})}else a?n=t.changeByRange(d=>{let h=s.line(l++);return{changes:{from:d.from,to:d.to,insert:h.text},range:H.cursor(d.from+h.length)}}):n=t.replaceSelection(s);o.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Ee.scroll=o=>{o.inputState.lastScrollTop=o.scrollDOM.scrollTop,o.inputState.lastScrollLeft=o.scrollDOM.scrollLeft},Pe.keydown=(o,e)=>(o.inputState.setSelectionOrigin("select"),e.keyCode==27&&o.inputState.tabFocusMode!=0&&(o.inputState.tabFocusMode=Date.now()+2e3),!1),Ee.touchstart=(o,e)=>{o.inputState.lastTouchTime=Date.now(),o.inputState.setSelectionOrigin("select.pointer")},Ee.touchmove=o=>{o.inputState.setSelectionOrigin("select.pointer")},Pe.mousedown=(o,e)=>{if(o.observer.flush(),o.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of o.state.facet(Ys))if(t=n(o,e),t)break;if(!t&&e.button==0&&(t=rh(o,e)),t){let n=!o.hasFocus;o.inputState.startMouseSelection(new eh(o,e,t,n)),n&&o.observer.ignore(()=>{Cs(o.contentDOM);let s=o.root.activeElement;s&&!s.contains(o.contentDOM)&&s.blur()});let l=o.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}return!1};function So(o,e,t,n){if(n==1)return H.cursor(e,t);if(n==2)return Ec(o.state,e,t);{let l=fe.find(o.docView,e),s=o.state.doc.lineAt(l?l.posAtEnd:e),a=l?l.posAtStart:s.from,r=l?l.posAtEnd:s.to;return r<o.state.doc.length&&r==s.to&&r++,H.range(a,r)}}let No=(o,e,t)=>e>=t.top&&e<=t.bottom&&o>=t.left&&o<=t.right;function oh(o,e,t,n){let l=fe.find(o.docView,e);if(!l)return 1;let s=e-l.posAtStart;if(s==0)return 1;if(s==l.length)return-1;let a=l.coordsAt(s,-1);if(a&&No(t,n,a))return-1;let r=l.coordsAt(s,1);return r&&No(t,n,r)?1:a&&a.bottom>=n?-1:1}function Bo(o,e){let t=o.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:oh(o,t,e.clientX,e.clientY)}}const ah=W.ie&&W.ie_version<=11;let Oo=null,Vo=0,_o=0;function Mo(o){if(!ah)return o.detail;let e=Oo,t=_o;return Oo=o,_o=Date.now(),Vo=!e||t>Date.now()-400&&Math.abs(e.clientX-o.clientX)<2&&Math.abs(e.clientY-o.clientY)<2?(Vo+1)%3:1}function rh(o,e){let t=Bo(o,e),n=Mo(e),l=o.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),l=l.map(s.changes))},get(s,a,r){let d=Bo(o,s),h,f=So(o,d.pos,d.bias,n);if(t.pos!=d.pos&&!a){let c=So(o,t.pos,t.bias,n),u=Math.min(c.from,f.from),m=Math.max(c.to,f.to);f=u<f.from?H.range(u,m):H.range(m,u)}return a?l.replaceRange(l.main.extend(f.from,f.to)):r&&n==1&&l.ranges.length>1&&(h=dh(l,d.pos))?h:r?l.addRange(f):H.create([f])}}}function dh(o,e){for(let t=0;t<o.ranges.length;t++){let{from:n,to:l}=o.ranges[t];if(n<=e&&l>=e)return H.create(o.ranges.slice(0,t).concat(o.ranges.slice(t+1)),o.mainIndex==t?0:o.mainIndex-(o.mainIndex>t?1:0))}return null}Pe.dragstart=(o,e)=>{let{selection:{main:t}}=o.state;if(e.target.draggable){let l=o.docView.nearest(e.target);if(l&&l.isWidget){let s=l.posAtStart,a=s+l.length;(s>=t.to||a<=t.from)&&(t=H.range(s,a))}}let{inputState:n}=o;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",zi(o.state,Xn,o.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Pe.dragend=o=>(o.inputState.draggedContent=null,!1);function To(o,e,t,n){if(t=zi(o.state,Yn,t),!t)return;let l=o.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=o.inputState,a=n&&s&&ih(o,e)?{from:s.from,to:s.to}:null,r={from:l,insert:t},d=o.state.changes(a?[a,r]:r);o.focus(),o.dispatch({changes:d,selection:{anchor:d.mapPos(l,-1),head:d.mapPos(l,1)},userEvent:a?"move.drop":"input.drop"}),o.inputState.draggedContent=null}Pe.drop=(o,e)=>{if(!e.dataTransfer)return!1;if(o.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),l=0,s=()=>{++l==t.length&&To(o,e,n.filter(a=>a!=null).join(o.state.lineBreak),!1)};for(let a=0;a<t.length;a++){let r=new FileReader;r.onerror=s,r.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(r.result)||(n[a]=r.result),s()},r.readAsText(t[a])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return To(o,e,n,!0),!0}return!1},Pe.paste=(o,e)=>{if(o.state.readOnly)return!0;o.observer.flush();let t=vo?null:e.clipboardData;return t?(Co(o,t.getData("text/plain")||t.getData("text/uri-list")),!0):(sh(o),!1)};function ch(o,e){let t=o.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),o.focus()},50)}function hh(o){let e=[],t=[],n=!1;for(let l of o.selection.ranges)l.empty||(e.push(o.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:s}of o.selection.ranges){let a=o.doc.lineAt(s);a.number>l&&(e.push(a.text),t.push({from:a.from,to:Math.min(o.doc.length,a.to+1)})),l=a.number}n=!0}return{text:zi(o,Xn,e.join(o.lineBreak)),ranges:t,linewise:n}}let sl=null;Pe.copy=Pe.cut=(o,e)=>{let{text:t,ranges:n,linewise:l}=hh(o.state);if(!t&&!l)return!1;sl=l?t:null,e.type=="cut"&&!o.state.readOnly&&o.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=vo?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(ch(o,t),!1)};const Ao=Nt.define();function Eo(o,e){let t=[];for(let n of o.facet(Zs)){let l=n(o,e);l&&t.push(l)}return t?o.update({effects:t,annotations:Ao.of(!0)}):null}function Io(o){setTimeout(()=>{let e=o.hasFocus;if(e!=o.inputState.notifiedFocused){let t=Eo(o.state,e);t?o.dispatch(t):o.update([])}},10)}Ee.focus=o=>{o.inputState.lastFocusTime=Date.now(),!o.scrollDOM.scrollTop&&(o.inputState.lastScrollTop||o.inputState.lastScrollLeft)&&(o.scrollDOM.scrollTop=o.inputState.lastScrollTop,o.scrollDOM.scrollLeft=o.inputState.lastScrollLeft),Io(o)},Ee.blur=o=>{o.observer.clearSelectionRange(),Io(o)},Ee.compositionstart=Ee.compositionupdate=o=>{o.observer.editContext||(o.inputState.compositionFirstChange==null&&(o.inputState.compositionFirstChange=!0),o.inputState.composing<0&&(o.inputState.composing=0))},Ee.compositionend=o=>{o.observer.editContext||(o.inputState.composing=-1,o.inputState.compositionEndedAt=Date.now(),o.inputState.compositionPendingKey=!0,o.inputState.compositionPendingChange=o.observer.pendingRecords().length>0,o.inputState.compositionFirstChange=null,W.chrome&&W.android?o.observer.flushSoon():o.inputState.compositionPendingChange?Promise.resolve().then(()=>o.observer.flush()):setTimeout(()=>{o.inputState.composing<0&&o.docView.hasComposition&&o.update([])},50))},Ee.contextmenu=o=>{o.inputState.lastContextMenu=Date.now()},Pe.beforeinput=(o,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&o.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(s&&a.length){let r=a[0],d=o.posAtDOM(r.startContainer,r.startOffset),h=o.posAtDOM(r.endContainer,r.endOffset);return ll(o,{from:d,to:h,insert:o.state.toText(s)},null),!0}}let l;if(W.chrome&&W.android&&(l=xo.find(s=>s.inputType==e.inputType))&&(o.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>s+10&&o.hasFocus&&(o.contentDOM.blur(),o.focus())},100)}return W.ios&&e.inputType=="deleteContentForward"&&o.observer.flushSoon(),W.safari&&e.inputType=="insertText"&&o.inputState.composing>=0&&setTimeout(()=>Ee.compositionend(o,e),20),!1};const Do=new Set;function fh(o){Do.has(o)||(Do.add(o),o.addEventListener("copy",()=>{}),o.addEventListener("cut",()=>{}))}const Po=["pre-wrap","normal","pre-line","break-spaces"];let Dt=!1;function Fo(){Dt=!1}class uh{constructor(e){this.lineWrapping=e,this.doc=ie.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Po.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let l=e[n];l<0?n++:this.heightSamples[Math.floor(l*10)]||(t=!0,this.heightSamples[Math.floor(l*10)]=!0)}return t}refresh(e,t,n,l,s,a){let r=Po.indexOf(e)>-1,d=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=t,this.charWidth=n,this.textHeight=l,this.lineLength=s,d){this.heightSamples={};for(let h=0;h<a.length;h++){let f=a[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return d}}class ph{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class We{constructor(e,t,n,l,s){this.from=e,this.length=t,this.top=n,this.height=l,this._content=s}get type(){return typeof this._content=="number"?ze.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof at?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new We(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var de=function(o){return o[o.ByPos=0]="ByPos",o[o.ByHeight=1]="ByHeight",o[o.ByPosNoHeight=2]="ByPosNoHeight",o}(de||(de={}));const qi=.001;class Se{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>qi&&(Dt=!0),this.height=e)}replace(e,t,n){return Se.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,l){let s=this,a=n.doc;for(let r=l.length-1;r>=0;r--){let{fromA:d,toA:h,fromB:f,toB:c}=l[r],u=s.lineAt(d,de.ByPosNoHeight,n.setDoc(t),0,0),m=u.to>=h?u:s.lineAt(h,de.ByPosNoHeight,n,0,0);for(c+=m.to-h,h=m.to;r>0&&u.from<=l[r-1].toA;)d=l[r-1].fromA,f=l[r-1].fromB,r--,d<u.from&&(u=s.lineAt(d,de.ByPosNoHeight,n,0,0));f+=u.from-d,d=u.from;let b=ol.build(n.setDoc(a),e,f,c);s=Ui(s,s.replace(d,h,b))}return s.updateHeight(n,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,l=0,s=0;for(;;)if(t==n)if(l>s*2){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,l-=r.size}else if(s>l*2){let r=e[n];r.break?e.splice(n,1,r.left,null,r.right):e.splice(n,1,r.left,r.right),n+=2+r.break,s-=r.size}else break;else if(l<s){let r=e[t++];r&&(l+=r.size)}else{let r=e[--n];r&&(s+=r.size)}let a=0;return e[t-1]==null?(a=1,t--):e[t]==null&&(a=1,n++),new mh(Se.of(e.slice(0,t)),a,Se.of(e.slice(n)))}}function Ui(o,e){return o==e?o:(o.constructor!=e.constructor&&(Dt=!0),e)}Se.prototype.size=1;class $o extends Se{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,l){return new We(l,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,l,s){return this.blockAt(0,n,l,s)}forEachLine(e,t,n,l,s,a){e<=s+this.length&&t>=s&&a(this.blockAt(0,n,l,s))}updateHeight(e,t=0,n=!1,l){return l&&l.from<=t&&l.more&&this.setHeight(l.heights[l.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class _e extends $o{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,l){return new We(l,this.length,n,this.height,this.breaks)}replace(e,t,n){let l=n[0];return n.length==1&&(l instanceof _e||l instanceof ye&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof ye?l=new _e(l.length,this.height):l.height=this.height,this.outdated||(l.outdated=!1),l):Se.of(n)}updateHeight(e,t=0,n=!1,l){return l&&l.from<=t&&l.more?this.setHeight(l.heights[l.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ye extends Se{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,s=l-n+1,a,r=0;if(e.lineWrapping){let d=Math.min(this.height,e.lineHeight*s);a=d/s,this.length>s+1&&(r=(this.height-d)/(this.length-s-1))}else a=this.height/s;return{firstLine:n,lastLine:l,perLine:a,perChar:r}}blockAt(e,t,n,l){let{firstLine:s,lastLine:a,perLine:r,perChar:d}=this.heightMetrics(t,l);if(t.lineWrapping){let h=l+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),f=t.doc.lineAt(h),c=r+f.length*d,u=Math.max(n,e-c/2);return new We(f.from,f.length,u,c,0)}else{let h=Math.max(0,Math.min(a-s,Math.floor((e-n)/r))),{from:f,length:c}=t.doc.line(s+h);return new We(f,c,n+r*h,r,0)}}lineAt(e,t,n,l,s){if(t==de.ByHeight)return this.blockAt(e,n,l,s);if(t==de.ByPosNoHeight){let{from:m,to:b}=n.doc.lineAt(e);return new We(m,b-m,0,0,0)}let{firstLine:a,perLine:r,perChar:d}=this.heightMetrics(n,s),h=n.doc.lineAt(e),f=r+h.length*d,c=h.number-a,u=l+r*c+d*(h.from-s-c);return new We(h.from,h.length,Math.max(l,Math.min(u,l+this.height-f)),f,0)}forEachLine(e,t,n,l,s,a){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:r,perLine:d,perChar:h}=this.heightMetrics(n,s);for(let f=e,c=l;f<=t;){let u=n.doc.lineAt(f);if(f==e){let b=u.number-r;c+=d*b+h*(e-s-b)}let m=d+h*u.length;a(new We(u.from,u.length,c,m,0)),c+=m,f=u.to+1}}replace(e,t,n){let l=this.length-t;if(l>0){let s=n[n.length-1];s instanceof ye?n[n.length-1]=new ye(s.length+l):n.push(null,new ye(l-1))}if(e>0){let s=n[0];s instanceof ye?n[0]=new ye(e+s.length):n.unshift(new ye(e-1),null)}return Se.of(n)}decomposeLeft(e,t){t.push(new ye(e-1),null)}decomposeRight(e,t){t.push(null,new ye(this.length-e-1))}updateHeight(e,t=0,n=!1,l){let s=t+this.length;if(l&&l.from<=t+this.length&&l.more){let a=[],r=Math.max(t,l.from),d=-1;for(l.from>t&&a.push(new ye(l.from-t-1).updateHeight(e,t));r<=s&&l.more;){let f=e.doc.lineAt(r).length;a.length&&a.push(null);let c=l.heights[l.index++];d==-1?d=c:Math.abs(c-d)>=qi&&(d=-2);let u=new _e(f,c);u.outdated=!1,a.push(u),r+=f+1}r<=s&&a.push(null,new ye(s-r).updateHeight(e,r));let h=Se.of(a);return(d<0||Math.abs(h.height-this.height)>=qi||Math.abs(d-this.heightMetrics(e,t).perLine)>=qi)&&(Dt=!0),Ui(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class mh extends Se{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,l){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,l):this.right.blockAt(e,t,s,l+this.left.length+this.break)}lineAt(e,t,n,l,s){let a=l+this.left.height,r=s+this.left.length+this.break,d=t==de.ByHeight?e<a:e<r,h=d?this.left.lineAt(e,t,n,l,s):this.right.lineAt(e,t,n,a,r);if(this.break||(d?h.to<r:h.from>r))return h;let f=t==de.ByPosNoHeight?de.ByPosNoHeight:de.ByPos;return d?h.join(this.right.lineAt(r,f,n,a,r)):this.left.lineAt(r,f,n,l,s).join(h)}forEachLine(e,t,n,l,s,a){let r=l+this.left.height,d=s+this.left.length+this.break;if(this.break)e<d&&this.left.forEachLine(e,t,n,l,s,a),t>=d&&this.right.forEachLine(e,t,n,r,d,a);else{let h=this.lineAt(d,de.ByPos,n,l,s);e<h.from&&this.left.forEachLine(e,h.from-1,n,l,s,a),h.to>=e&&h.from<=t&&a(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,r,d,a)}}replace(e,t,n){let l=this.left.length+this.break;if(t<l)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,n));let s=[];e>0&&this.decomposeLeft(e,s);let a=s.length;for(let r of n)s.push(r);if(e>0&&Ro(s,a-1),t<this.length){let r=s.length;this.decomposeRight(t,s),Ro(s,r)}return Se.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,l=n+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<l&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Se.of(this.break?[e,null,t]:[e,t]):(this.left=Ui(this.left,e),this.right=Ui(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,l){let{left:s,right:a}=this,r=t+s.length+this.break,d=null;return l&&l.from<=t+s.length&&l.more?d=s=s.updateHeight(e,t,n,l):s.updateHeight(e,t,n),l&&l.from<=r+a.length&&l.more?d=a=a.updateHeight(e,r,n,l):a.updateHeight(e,r,n),d?this.balanced(s,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ro(o,e){let t,n;o[e]==null&&(t=o[e-1])instanceof ye&&(n=o[e+1])instanceof ye&&o.splice(e-1,3,new ye(t.length+1+n.length))}const gh=5;class ol{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof _e?l.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new _e(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let l=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;l<0&&(l=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new $o(a,l,n)):(a||s||l>=gh)&&this.addLineDeco(l,s,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new ye(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _e)return e;let t=new _e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let l=this.ensureLine();l.length+=n,l.collapsed+=n,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let l of this.nodes)l instanceof _e&&l.updateHeight(this.oracle,n),n+=l?l.length:1;return this.nodes}static build(e,t,n,l){let s=new ol(n,e);return re.spans(t,n,l,s,0),s.finish(n)}}function kh(o,e,t){let n=new bh;return re.compare(o,e,t,n,0),n.changes}class bh{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,l){(e<t||n&&n.heightRelevant||l&&l.heightRelevant)&&qn(e,t,this.changes,5)}}function yh(o,e){let t=o.getBoundingClientRect(),n=o.ownerDocument,l=n.defaultView||window,s=Math.max(0,t.left),a=Math.min(l.innerWidth,t.right),r=Math.max(0,t.top),d=Math.min(l.innerHeight,t.bottom);for(let h=o.parentNode;h&&h!=n.body;)if(h.nodeType==1){let f=h,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();s=Math.max(s,u.left),a=Math.min(a,u.right),r=Math.max(r,u.top),d=Math.min(h==o.parentNode?l.innerHeight:d,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,a)-t.left,top:r-(t.top+e),bottom:Math.max(r,d)-(t.top+e)}}function wh(o,e){let t=o.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class al{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let l=e[n],s=t[n];if(l.from!=s.from||l.to!=s.to||l.size!=s.size)return!1}return!0}draw(e,t){return Ce.replace({widget:new xh(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class xh extends zn{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Lo{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=jo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=be.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Zn).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new uh(t),this.stateDeco=e.facet(si).filter(n=>typeof n!="function"),this.heightMap=Se.empty().applyChanges(this.stateDeco,ie.empty,this.heightOracle.setDoc(e.doc),[new Ae(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ce.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let l=n?t.head:t.anchor;if(!e.some(({from:s,to:a})=>l>=s&&l<=a)){let{from:s,to:a}=this.lineBlockAt(l);e.push(new Wi(s,a))}}return this.viewports=e.sort((n,l)=>n.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?jo:new rl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ri(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(si).filter(f=>typeof f!="function");let l=e.changedRanges,s=Ae.extendWithRanges(l,kh(n,this.stateDeco,e?e.changes:me.empty(this.state.doc.length))),a=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Fo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=a||Dt)&&(e.flags|=2),r?(this.scrollAnchorPos=e.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let d=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<d.from||t.range.head>d.to)||!this.viewportIsAppropriate(d))&&(d=this.getViewport(0,t));let h=d.from!=this.viewport.from||d.to!=this.viewport.to;this.viewport=d,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Sc)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),l=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?be.RTL:be.LTR;let a=this.heightOracle.mustRefreshForWrapping(s),r=t.getBoundingClientRect(),d=a||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let h=0,f=0;if(r.width&&r.height){let{scaleX:g,scaleY:p}=vs(t,r);(g>.005&&Math.abs(this.scaleX-g)>.005||p>.005&&Math.abs(this.scaleY-p)>.005)&&(this.scaleX=g,this.scaleY=p,h|=8,a=d=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(d=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=Bs(e.scrollDOM);let b=(this.printing?wh:yh)(t,this.paddingTop),y=b.top-this.pixelViewport.top,k=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(d=!0)),!this.inView&&!this.scrollTarget)return 0;let w=r.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=r.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),d){let g=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(g)&&(a=!0),a||l.lineWrapping&&Math.abs(w-this.contentDOMWidth)>l.charWidth){let{lineHeight:p,charWidth:N,textHeight:V}=e.docView.measureTextSize();a=p>0&&l.refresh(s,p,N,V,w/N,g),a&&(e.docView.minWidth=0,h|=8)}y>0&&k>0?f=Math.max(y,k):y<0&&k<0&&(f=Math.min(y,k)),Fo();for(let p of this.viewports){let N=p.from==this.viewport.from?g:e.docView.measureVisibleLineHeights(p);this.heightMap=(a?Se.empty().applyChanges(this.stateDeco,ie.empty,this.heightOracle,[new Ae(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new ph(p.from,N))}Dt&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,s=this.heightOracle,{visibleTop:a,visibleBottom:r}=this,d=new Wi(l.lineAt(a-n*1e3,de.ByHeight,s,0,0).from,l.lineAt(r+(1-n)*1e3,de.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<d.from||h>d.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=l.lineAt(h,de.ByPos,s,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h<d.from?u=c.top:u=c.bottom-f,d=new Wi(l.lineAt(u-1e3/2,de.ByHeight,s,0,0).from,l.lineAt(u+f+1e3/2,de.ByHeight,s,0,0).to)}}return d}mapViewport(e,t){let n=t.mapPos(e.from,-1),l=t.mapPos(e.to,1);return new Wi(this.heightMap.lineAt(n,de.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(l,de.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:l}=this.heightMap.lineAt(e,de.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,de.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:r}=this;return(e==0||l<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=r+Math.max(10,Math.min(n,250)))&&l>a-2*1e3&&s<r+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let l of e)t.touchesRange(l.from,l.to)||n.push(new al(t.mapPos(l.from),t.mapPos(l.to),l.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,l=n?1e4:2e3,s=l>>1,a=l<<1;if(this.defaultTextDirection!=be.LTR&&!n)return[];let r=[],d=(f,c,u,m)=>{if(c-f<s)return;let b=this.state.selection.main,y=[b.from];b.empty||y.push(b.to);for(let v of y)if(v>f&&v<c){d(f,v-10,u,m),d(v+10,c,u,m);return}let k=Ch(e,v=>v.from>=u.from&&v.to<=u.to&&Math.abs(v.from-f)<s&&Math.abs(v.to-c)<s&&!y.some(w=>v.from<w&&v.to>w));if(!k){if(c<u.to&&t&&n&&t.visibleRanges.some(v=>v.from<=c&&v.to>=c)){let v=t.moveToLineBoundary(H.cursor(c),!1,!0).head;v>f&&(c=v)}k=new al(f,c,this.gapSize(u,f,c,m))}r.push(k)},h=f=>{if(f.length<a||f.type!=ze.Text)return;let c=vh(f.from,f.to,this.stateDeco);if(c.total<a)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,m,b;if(n){let y=l/this.heightOracle.lineLength*this.heightOracle.lineHeight,k,v;if(u!=null){let w=Ki(c,u),O=((this.visibleBottom-this.visibleTop)/2+y)/f.height;k=w-O,v=w+O}else k=(this.visibleTop-f.top-y)/f.height,v=(this.visibleBottom-f.top+y)/f.height;m=Hi(c,k),b=Hi(c,v)}else{let y=c.total*this.heightOracle.charWidth,k=l*this.heightOracle.charWidth,v,w;if(u!=null){let O=Ki(c,u),g=((this.pixelViewport.right-this.pixelViewport.left)/2+k)/y;v=O-g,w=O+g}else v=(this.pixelViewport.left-k)/y,w=(this.pixelViewport.right+k)/y;m=Hi(c,v),b=Hi(c,w)}m>f.from&&d(f.from,m,f,c),b<f.to&&d(b,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return r}gapSize(e,t,n,l){let s=Ki(l,n)-Ki(l,t);return this.heightOracle.lineWrapping?e.height*s:l.total*this.heightOracle.charWidth*s}updateLineGaps(e){al.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ce.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];re.spans(e,this.viewport.from,this.viewport.to,{span(l,s){t.push({from:l,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((l,s)=>l.from!=t[s].from||l.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ri(this.heightMap.lineAt(e,de.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ri(this.heightMap.lineAt(this.scaler.fromDOM(e),de.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ri(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Wi{constructor(e,t){this.from=e,this.to=t}}function vh(o,e,t){let n=[],l=o,s=0;return re.spans(t,o,e,{span(){},point(a,r){a>l&&(n.push({from:l,to:a}),s+=a-l),l=r}},20),l<e&&(n.push({from:l,to:e}),s+=e-l),{total:s,ranges:n}}function Hi({total:o,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(o*t);for(let l=0;;l++){let{from:s,to:a}=e[l],r=a-s;if(n<=r)return s+n;n-=r}}function Ki(o,e){let t=0;for(let{from:n,to:l}of o.ranges){if(e<=l){t+=e-n;break}t+=l-n}return t/o.total}function Ch(o,e){for(let t of o)if(e(t))return t}const jo={toDOM(o){return o},fromDOM(o){return o},scale:1,eq(o){return o==this}};class rl{constructor(e,t,n){let l=0,s=0,a=0;this.viewports=n.map(({from:r,to:d})=>{let h=t.lineAt(r,de.ByPos,e,0,0).top,f=t.lineAt(d,de.ByPos,e,0,0).bottom;return l+=f-h,{from:r,to:d,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-l)/(t.height-l);for(let r of this.viewports)r.domTop=a+(r.top-s)*this.scale,a=r.domBottom=r.domTop+(r.bottom-r.top),s=r.bottom}toDOM(e){for(let t=0,n=0,l=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return l+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,l=s.domBottom}}fromDOM(e){for(let t=0,n=0,l=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-l)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,l=s.domBottom}}eq(e){return e instanceof rl?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function ri(o,e){if(e.scale==1)return o;let t=e.toDOM(o.top),n=e.toDOM(o.bottom);return new We(o.from,o.length,t,n-t,Array.isArray(o._content)?o._content.map(l=>ri(l,e)):o._content)}const Qi=Y.define({combine:o=>o.join(" ")}),dl=Y.define({combine:o=>o.indexOf(!0)>-1}),cl=ot.newName(),zo=ot.newName(),qo=ot.newName(),Uo={"&light":"."+zo,"&dark":"."+qo};function hl(o,e,t){return new ot(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,l=>{if(l=="&")return o;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):o+" "+n}})}const Sh=hl("."+cl,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Uo),Nh={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},fl=W.ie&&W.ie_version<=11;class Bh{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new ac,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(W.ie&&W.ie_version<=11||W.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(W.chrome&&W.chrome_version<126)&&(this.editContext=new Vh(e),e.state.facet(dt)&&(e.contentDOM.editContext=this.editContext.editContext)),fl&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,l=this.selectionRange;if(n.state.facet(dt)?n.root.activeElement!=this.dom:!Ti(n.dom,l))return;let s=l.anchorNode&&n.docView.nearest(l.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(W.ie&&W.ie_version<=11||W.android&&W.chrome)&&!n.state.selection.main.empty&&l.focusNode&&ei(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Jt(e.root);if(!t)return!1;let n=W.safari&&e.root.nodeType==11&&nc(this.dom.ownerDocument)==this.dom&&Oh(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let l=Ti(this.dom,n);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&dc(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),l&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Nh),fl&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),fl&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let l=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Mt(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,l=!1;for(let s of e){let a=this.readMutation(s);a&&(a.typeOver&&(l=!0),t==-1?{from:t,to:n}=a:(t=Math.min(a.from,t),n=Math.max(a.to,n)))}return{from:t,to:n,typeOver:l}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),l=this.selectionChanged&&Ti(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Uc(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,l=yo(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),l}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=Wo(t,e.previousSibling||e.target.previousSibling,-1),l=Wo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(dt)!=e.state.facet(dt)&&(e.view.contentDOM.editContext=e.state.facet(dt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let l of this.scrollTargets)l.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Wo(o,e,t){for(;e;){let n=oe.get(e);if(n&&n.parent==o)return n;let l=e.parentNode;e=l!=o.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function Ho(o,e){let t=e.startContainer,n=e.startOffset,l=e.endContainer,s=e.endOffset,a=o.docView.domAtPos(o.state.selection.main.anchor);return ei(a.node,a.offset,l,s)&&([t,n,l,s]=[l,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:l,focusOffset:s}}function Oh(o,e){if(e.getComposedRanges){let l=e.getComposedRanges(o.root)[0];if(l)return Ho(o,l)}let t=null;function n(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return o.contentDOM.addEventListener("beforeinput",n,!0),o.dom.ownerDocument.execCommand("indent"),o.contentDOM.removeEventListener("beforeinput",n,!0),t?Ho(o,t):null}class Vh{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let{anchor:l}=e.state.selection.main,s={from:this.toEditorPos(n.updateRangeStart),to:this.toEditorPos(n.updateRangeEnd),insert:ie.of(n.text.split(`
10
- `))};s.from==this.from&&l<this.from?s.from=l:s.to==this.to&&l>this.to&&(s.to=l),!(s.from==s.to&&!s.insert.length)&&(this.pendingContextChange=s,e.state.readOnly||ll(e,s,H.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=n=>{let l=[],s=null;for(let a=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);a<r;a++){let d=e.coordsForChar(a);s=d&&new DOMRect(d.left,d.top,d.right-d.left,d.bottom-d.top)||s||new DOMRect,l.push(s)}t.updateCharacterBounds(n.rangeStart,l)},this.handlers.textformatupdate=n=>{let l=[];for(let s of n.getTextFormats()){let a=s.underlineStyle,r=s.underlineThickness;if(a!="None"&&r!="None"){let d=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${r=="Thin"?1:2}px`;l.push(Ce.mark({attributes:{style:d}}).range(this.toEditorPos(s.rangeStart),this.toEditorPos(s.rangeEnd)))}}e.dispatch({effects:io.of(Ce.set(l))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let l=Jt(n.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,l=this.pendingContextChange;return e.changes.iterChanges((s,a,r,d,h)=>{if(n)return;let f=h.length-(a-s);if(l&&a>=l.to)if(l.from==s&&l.to==a&&l.insert.eq(h)){l=this.pendingContextChange=null,t+=f,this.to+=f;return}else l=null,this.revertPending(e.state);if(s+=t,a+=t,a<=this.from)this.from+=f,this.to+=f;else if(s<this.to){if(s<this.from||a>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),h.toString()),this.to+=f}t+=f}),l&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(n,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class le{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(l=>l.forEach(s=>n(s,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||rc(e.parent)||document,this.viewState=new Lo(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Fi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(li).map(l=>new Jn(l));for(let l of this.plugins)l.update(this);this.observer=new Bh(this),this.inputState=new Gc(this),this.inputState.ensureHandlers(this.plugins),this.docView=new co(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,l,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,r=0,d=null;e.some(u=>u.annotation(Ao))?(this.inputState.notifiedFocused=a,r=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,d=Eo(s,a),d||(r=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(f=null)):this.observer.clear(),s.facet(se.phrases)!=this.state.facet(se.phrases))return this.setState(s);l=$i.create(this,s,e),l.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:m}=u.state.selection;c=new Et(m.empty?m:H.cursor(m.head,m.head>m.anchor?-1:1))}for(let m of u.effects)m.is(Fi)&&(c=m.value.clip(this.state))}this.viewState.update(l,c),this.bidiCache=Gi.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(oi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(Qi)!=l.state.facet(Qi)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let u of this.state.facet(Gn))try{u(l)}catch(m){Ue(this.state,m,"update listener")}(d||f)&&Promise.resolve().then(()=>{d&&this.state==d.startState&&this.dispatch(d),f&&!yo(this,f)&&h.force&&Mt(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Lo(e),this.plugins=e.facet(li).map(n=>new Jn(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new co(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(li),n=e.state.facet(li);if(t!=n){let l=[];for(let s of n){let a=t.indexOf(s);if(a<0)l.push(new Jn(s));else{let r=this.plugins[a];r.mustUpdate=e,l.push(r)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l<this.plugins.length;l++)this.plugins[l].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Ue(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,l=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(l-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let r=0;;r++){if(a<0)if(Bs(n))s=-1,a=this.viewState.heightMap.height;else{let m=this.viewState.scrollAnchorAt(l);s=m.from,a=m.top}this.updateState=1;let d=this.viewState.measure(this);if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(r>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];d&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(m=>{try{return m.read(this)}catch(b){return Ue(this.state,b),Ko}}),c=$i.create(this,this.state,[]),u=!1;c.flags|=d,t?t.flags|=d:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let m=0;m<h.length;m++)if(f[m]!=Ko)try{let b=h[m];b.write&&b.write(f[m],this)}catch(b){Ue(this.state,b)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let b=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-a;if(b>1||b<-1){l=l+b,n.scrollTop=l/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let r of this.state.facet(Gn))r(t)}get themeClasses(){return cl+" "+(this.state.facet(dl)?qo:zo)+" "+this.state.facet(Qi)}updateAttrs(){let e=Qo(this,no,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(dt)?"true":"false",class:"cm-content",style:`${W.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Qo(this,Zn,t);let n=this.observer.ignore(()=>{let l=jn(this.contentDOM,this.contentAttrs,t),s=jn(this.dom,this.editorAttrs,e);return l||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let l of n.effects)if(l.is(le.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(oi);let e=this.state.facet(le.cspNonce);ot.mount(this.root,this.styleModules.concat(Sh).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return nl(this,e,ko(this,e,t,n))}moveByGroup(e,t){return nl(this,e,ko(this,e,t,n=>Lc(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),l=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return H.cursor(s.side(t,l)+e.from,s.forward(!t,l)?1:-1)}moveToLineBoundary(e,t,n=!0){return Rc(this,e,t,n)}moveVertically(e,t,n){return nl(this,e,jc(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),mo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let l=this.state.doc.lineAt(e),s=this.bidiSpans(l),a=s[rt.find(s,e-l.from,-1,t)];return Ei(n,a.dir==be.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(eo)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>_h)return Hs(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Ws(s.isolates,n=oo(this,e))))return s.order;n||(n=oo(this,e));let l=xc(e.text,t,n);return this.bidiCache.push(new Gi(e.from,e.to,t,n,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||W.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Cs(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fi.of(new Et(typeof e=="number"?H.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Fi.of(new Et(H.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return It.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return It.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=ot.newName(),l=[Qi.of(n),oi.of(hl(`.${n}`,e))];return t&&t.dark&&l.push(dl.of(!0)),l}static baseTheme(e){return qd.lowest(oi.of(hl("."+cl,e,Uo)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),l=n&&oe.get(n)||oe.get(e);return((t=l?.rootView)===null||t===void 0?void 0:t.view)||null}}le.styleModule=oi,le.inputHandler=Js,le.clipboardInputFilter=Yn,le.clipboardOutputFilter=Xn,le.scrollHandler=to,le.focusChangeEffect=Zs,le.perLineTextDirection=eo,le.exceptionSink=Xs,le.updateListener=Gn,le.editable=dt,le.mouseSelectionStyle=Ys,le.dragMovesSelection=Gs,le.clickAddsSelectionRange=Qs,le.decorations=si,le.outerDecorations=lo,le.atomicRanges=el,le.bidiIsolatedRanges=so,le.scrollMargins=ao,le.darkTheme=dl,le.cspNonce=Y.define({combine:o=>o.length?o[0]:""}),le.contentAttributes=Zn,le.editorAttributes=no,le.lineWrapping=le.contentAttributes.of({class:"cm-lineWrapping"}),le.announce=ue.define();const _h=4096,Ko={};class Gi{constructor(e,t,n,l,s,a){this.from=e,this.to=t,this.dir=n,this.isolates=l,this.fresh=s,this.order=a}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],l=e.length?e[e.length-1].dir:be.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let a=e[s];a.dir==l&&!t.touchesRange(a.from,a.to)&&n.push(new Gi(t.mapPos(a.from,1),t.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return n}}function Qo(o,e,t){for(let n=o.state.facet(e),l=n.length-1;l>=0;l--){let s=n[l],a=typeof s=="function"?s(o):s;a&&Ln(a,t)}return t}const Mh=!W.ios,Go={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Mh&&(Go[".cm-line"].caretColor=Go[".cm-content"].caretColor="transparent !important");class Pt extends Ot{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Pt.prototype.elementClass="",Pt.prototype.toDOM=void 0,Pt.prototype.mapMode=Ve.TrackBefore,Pt.prototype.startSide=Pt.prototype.endSide=-1,Pt.prototype.point=!0;var ul;const Ft=new te;function Th(o){return Y.define({combine:o?e=>e.concat(o):void 0})}const Ah=new te;class Fe{constructor(e,t,n=[],l=""){this.data=e,this.name=l,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return pl(this)}}),this.parser=t,this.extension=[Rt.of(this),se.languageData.of((s,a,r)=>{let d=Yo(s,a,r),h=d.type.prop(Ft);if(!h)return[];let f=s.facet(h),c=d.type.prop(Ah);if(c){let u=d.resolve(a-d.from,r);for(let m of c)if(m.test(u,s)){let b=s.facet(m.facet);return m.type=="replace"?b:b.concat(f)}}return f})].concat(n)}isActiveAt(e,t,n=-1){return Yo(e,t,n).type.prop(Ft)==this.data}findRegions(e){let t=e.facet(Rt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],l=(s,a)=>{if(s.prop(Ft)==this.data){n.push({from:a,to:a+s.length});return}let r=s.prop(te.mounted);if(r){if(r.tree.prop(Ft)==this.data){if(r.overlay)for(let d of r.overlay)n.push({from:d.from+a,to:d.to+a});else n.push({from:a,to:a+s.length});return}else if(r.overlay){let d=n.length;if(l(r.tree,r.overlay[0].from+a),n.length>d)return}}for(let d=0;d<s.children.length;d++){let h=s.children[d];h instanceof he&&l(h,s.positions[d]+a)}};return l(pl(e),0),n}get allowsNesting(){return!0}}Fe.setState=ue.define();function Yo(o,e,t){let n=o.facet(Rt),l=pl(o).topNode;if(!n||n.allowsNesting)for(let s=l;s;s=s.enter(e,t,pe.ExcludeBuffers))s.type.isTop&&(l=s);return l}class Yi extends Fe{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Th(e.languageData);return new Yi(t,e.parser.configure({props:[Ft.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Yi(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function pl(o){let e=o.field(Fe.state,!1);return e?e.tree:he.empty}class Eh{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let di=null;class Xi{constructor(e,t,n=[],l,s,a,r,d){this.parser=e,this.state=t,this.fragments=n,this.tree=l,this.treeLen=s,this.viewport=a,this.skipped=r,this.scheduleOn=d,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Xi(e,t,[],he.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Eh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=he.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let l=this.parse.advance();if(l)if(this.fragments=this.withoutTempSkipped(ut.addTree(l,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=l,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ut.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=di;di=this;try{return e()}finally{di=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Xo(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:l,treeLen:s,viewport:a,skipped:r}=this;if(this.takeTree(),!e.empty){let d=[];if(e.iterChangedRanges((h,f,c,u)=>d.push({fromA:h,toA:f,fromB:c,toB:u})),n=ut.applyChanges(n,d),l=he.empty,s=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){r=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);f<c&&r.push({from:f,to:c})}}}return new Xi(this.parser,t,n,l,s,a,r,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:l,to:s}=this.skipped[n];l<e.to&&s>e.from&&(this.fragments=Xo(this.fragments,l,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Dl{createParse(t,n,l){let s=l[0].from,a=l[l.length-1].to;return{parsedPos:s,advance(){let d=di;if(d){for(let h of l)d.tempSkipped.push(h);e&&(d.scheduleOn=d.scheduleOn?Promise.all([d.scheduleOn,e]):e)}return this.parsedPos=a,new he(Ne.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return di}}function Xo(o,e,t){return ut.applyChanges(o,[{fromA:e,toA:t,fromB:e,toB:t}])}class $t{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new $t(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Xi.create(e.facet(Rt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new $t(n)}}Fe.state=gt.define({create:$t.init,update(o,e){for(let t of e.effects)if(t.is(Fe.setState))return t.value;return e.startState.facet(Rt)!=e.state.facet(Rt)?$t.init(e.state):o.apply(e)}});let Jo=o=>{let e=setTimeout(()=>o(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Jo=o=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(o,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ml=typeof navigator<"u"&&(!((ul=navigator.scheduling)===null||ul===void 0)&&ul.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ih=It.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Fe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Fe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Jo(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:l}}=this.view,s=n.field(Fe.state);if(s.tree==s.context.tree&&s.context.isDone(l+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!ml?Math.max(25,e.timeRemaining()-5):1e9),r=s.context.treeLen<l&&n.doc.length>l+1e3,d=s.context.work(()=>ml&&ml()||Date.now()>a,l+(r?0:1e5));this.chunkBudget-=Date.now()-t,(d||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Fe.setState.of(new $t(s.context))})),this.chunkBudget>0&&!(d&&!r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ue(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Rt=Y.define({combine(o){return o.length?o[0]:null},enables:o=>[Fe.state,Ih,le.contentAttributes.compute([o],e=>{let t=e.facet(o);return t&&t.name?{"data-language":t.name}:{}})]});class Dh{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Ph=new te;function Zo({except:o,units:e=1}={}){return t=>{let n=o&&o.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const Fh=new te;function $h(o){let e=o.firstChild,t=o.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?o.to:t.from}:null}class gl{constructor(e,t){this.specs=e;let n;function l(r){let d=ot.newName();return(n||(n=Object.create(null)))["."+d]=r,d}const s=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof Fe?r=>r.prop(Ft)==a.data:a?r=>r==a:void 0,this.style=ql(e.map(r=>({tag:r.tag,class:r.class||l(Object.assign({},r,{tag:null}))})),{all:s}).style,this.module=n?new ot(n):null,this.themeType=t.themeType}static define(e,t){return new gl(e,t||{})}}z.meta,z.link,z.heading,z.emphasis,z.strong,z.strikethrough,z.keyword,z.atom,z.bool,z.url,z.contentSeparator,z.labelName,z.literal,z.inserted,z.string,z.deleted,z.regexp,z.escape,z.string,z.variableName,z.variableName,z.typeName,z.namespace,z.className,z.variableName,z.macroName,z.propertyName,z.comment,z.invalid;const Rh=Object.create(null),ea=[Ne.none],ta=[],ia=Object.create(null),Lh=Object.create(null);for(let[o,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Lh[o]=jh(Rh,e);function kl(o,e){ta.indexOf(o)>-1||(ta.push(o),console.warn(e))}function jh(o,e){let t=[];for(let r of e.split(" ")){let d=[];for(let h of r.split(".")){let f=o[h]||z[h];f?typeof f=="function"?d.length?d=d.map(f):kl(h,`Modifier ${h} used at start of tag`):d.length?kl(h,`Tag ${h} used as modifier`):d=Array.isArray(f)?f:[f]:kl(h,`Unknown highlighting tag ${h}`)}for(let h of d)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),l=n+" "+t.map(r=>r.id),s=ia[l];if(s)return s.id;let a=ia[l]=Ne.define({id:ea.length,name:n,props:[zl({[n]:t})]});return ea.push(a),a.id}be.RTL,be.LTR;const zh=Yi.define({name:"json",parser:Fd.configure({props:[Ph.add({Object:Zo({except:/^\s*\}/}),Array:Zo({except:/^\s*\]/})}),Fh.add({"Object Array":$h})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function qh(){return new Dh(zh)}const bl=[{name:"tel",title:"手机号",express:"^1[3-9]\\d{9}$",error:"手机号不正确"},{name:"email",title:"邮箱",express:"^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",error:"邮箱不正确"},{name:"idcard",title:"身份证号码",express:"(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)",error:"身份证号码不正确"}];function Uh(){const o=Ie();if(o.formRules?.length){const e={};bl.forEach(n=>{e[n.name]=n});const t=[...bl];return o.formRules.forEach(n=>{const l=e[n.name];l?Object.assign(l,n):t.push(l)}),t}return bl}const Wh={loadAdvances:Uh},Hh={class:"unione-props-setting data-field-setting"},Kh={key:0},Qh=["onClick"],Gh={class:"field-txt"},Yh=["onClick"],Xh={key:1,class:"field-txt"},Jh=["onClick"],Zh={key:0,class:"field-txt"},ef={key:3,class:"edit-field"},tf=["onClick"],nf=ne(i.defineComponent({__name:"dataFieldSetting",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=i.ref([qh()]),t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:g})=>g+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"form",key:"form",width:"40px",align:"center"},{title:"详情",dataIndex:"view",key:"view",width:"40px",align:"center"},{title:"列表",dataIndex:"list",key:"list",width:"40px",align:"center"},{title:"排序",dataIndex:"sort",key:"sort",width:"40px",align:"center"},{title:"查询",dataIndex:"query",key:"query",width:"40px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),n=i.useModel(o,"modelValue"),l={mounted:g=>g.focus()},s=i.ref({});function a(){const g=Object.keys(s.value);if(g.length)for(let p in g){const N=n.value.filter(V=>V.name==p);if(N&&N[0]){let V=s.value[p];Object.keys(V).forEach(C=>{C=="convertName"?(N[0].convert||(N[0].convert={}),N[0].convert.type=V[C]):N[0][C]=V[C]})}}s.value={}}function r(g,p){a();const N={};p=="convertName"?(g.convert||(g.convert={}),N[p]=g.convert?.type):N[p]=g[p]||"",s.value[g.name]=N}function d(g,p){{s.value={};return}}function h(g,p){switch(p){case"query":return g.configs?.query?.enable;case"form":return g.configs?.show?.form?.enable;case"view":return g.configs?.show?.view?.enable;case"list":return g.configs?.show?.list?.enable;case"sort":return g.configs?.sort?.enable}}function f(g,p){switch(p){case"query":g.configs=K.utils.obj.ext(g.configs,{query:{enable:!1}}),g.configs.query.enable=!g.configs.query.enable;break;case"form":g.configs=K.utils.obj.ext(g.configs,{show:{form:{enable:!1}}}),g.configs.show.form.enable=!g.configs.show.form.enable;break;case"view":g.configs=K.utils.obj.ext(g.configs,{show:{view:{enable:!1}}}),g.configs.show.view.enable=!g.configs.show.view.enable;break;case"list":g.configs=K.utils.obj.ext(g.configs,{show:{list:{enable:!1}}}),g.configs.show.list.enable=!g.configs.show.list.enable;break;case"sort":g.configs=K.utils.obj.ext(g.configs,{sort:{enable:!1}}),g.configs.sort.enable=!g.configs.sort.enable;break}console.log("record.configs",g.configs)}const c=i.ref({title:"列头设置",prop:"list",visible:!1,field:{},show:{},toSetting:()=>{c.value.visible=!1}});function u(g,p){switch(c.value.prop=p,c.value.field=g,g.configs||(g.configs={}),g.configs.show||(g.configs.show={}),p){case"query":g.configs.query||(g.configs.query={}),g.configs.query.types||(g.configs.query.types="EQ"),c.value.show=g.configs.query,c.value.title=`查询设置/${g.title}(${g.name})`;break;case"form":g.configs.show.form||(g.configs.show.form={}),c.value.show=g.configs.show.form,c.value.title=`表单设置/${g.title}(${g.name})`;break;case"view":g.configs.show.view||(g.configs.show.view={}),c.value.show=g.configs.show.view,c.value.title=`详情设置/${g.title}(${g.name})`;break;case"list":g.configs.show.list||(g.configs.show.list={}),c.value.show=g.configs.show.list,c.value.title=`列头设置/${g.title}(${g.name})`;break;case"sort":g.configs.sort||(g.configs.sort={}),c.value.show=g.configs.sort,c.value.title=`排序设置/${g.title}(${g.name})`;break}c.value.visible=!0}const m=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:g=>{const p=m.value.options.filter(N=>N.value==g);return p[0]?p[0].label:g}}),b=i.ref({visible:!1,field:{},props:{},advances:Wh.loadAdvances(),showInfo:g=>{let p=0;if(g.configs?.rule){const N=g.configs.rule;N.advance&&p++,typeof N.rangeMin<"u"&&p++,typeof N.rangeMax<"u"&&p++,typeof N.regExpress<"u"&&p++}if(p>0)return"("+p+")"},toSetting:()=>{const g=b.value.props;b.value.field.configs=K.utils.obj.ext(b.value.field.configs,{rule:{...g}}),b.value.visible=!1,b.value.props={}}});function y(g){b.value.visible=!0,b.value.field=g,b.value.props=g.configs?.rule||{}}const k=i.ref({visible:!1,field:{},widget:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-input-number",label:"数值框"},{value:"unione-check-box",label:"多选框"},{value:"unione-radio-box",label:"单选框"},{value:"unione-switch-box",label:"开关"},{value:"unione-select-box",label:"下拉框"},{value:"unione-tree-box",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-slider",label:"滑块"},{value:"a-textarea",label:"文本域"}],widgetName:g=>{const p=g.configs?.widget?.name,N=k.value.widgets.filter(V=>V.value==p);return N[0]?N[0].label:p},toSetting:(g,p)=>{g.configs||(g.configs={}),g.configs.widget||(g.configs.widget={}),g.configs.widget.name=p},toclose:()=>{k.value.visible=!1}});function v(g){k.value.field=g,g.configs=K.utils.obj.ext(g.configs,{widget:{props:{}}}),k.value.widget=g.configs.widget,k.value.visible=!0}const w=i.ref({visible:!1,field:{},convert:{},types:[{value:"dict",label:"字典"},{value:"option",label:"静态"},{value:"dbtable",label:"数据集"},{value:"remote",label:"远程接口"},{value:"local",label:"本地接口"}],optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],getTypes:(g,p="--")=>w.value.types.filter(N=>N.value==g)[0]?.label||p,toAddOption:()=>{w.value.convert.options||(w.value.convert.options=[]),w.value.convert.options.push({label:"",value:""})},toDelOption:(g,p)=>{w.value.convert.options.splice(g,1)},toSetting:()=>{w.value.visible=!1}});function O(g){w.value.visible=!0,w.value.field=g,g.configs||(g.configs={}),g.configs.convert||(g.configs.convert={}),w.value.convert=g.configs.convert}return(g,p)=>{const N=i.resolveComponent("ToolOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("a-select"),x=i.resolveComponent("a-checkbox"),S=i.resolveComponent("a-table"),M=i.resolveComponent("a-switch"),T=i.resolveComponent("a-form-item"),E=i.resolveComponent("a-select-option"),I=i.resolveComponent("a-input-number"),L=i.resolveComponent("a-form"),A=i.resolveComponent("a-modal"),U=i.resolveComponent("a-input"),P=i.resolveComponent("unione-select-box"),G=i.resolveComponent("a-checkbox-group"),j=i.resolveComponent("unione-section");return i.openBlock(),i.createElementBlock("div",Hh,[i.createVNode(S,{columns:t.value,"data-source":n.value,bordered:"",scroll:{x:1e3},pagination:!0,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:B})=>[["widget","queryType","rules","convertName"].includes(B.key)?(i.openBlock(),i.createElementBlock("span",Kh,[i.createVNode(N),i.createTextVNode(" "+i.toDisplayString(B.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:B,text:F,record:_})=>[["rules"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!b.value.showInfo(_)&&"empty"]),onClick:D=>y(_)},[i.createElementVNode("span",Gh,i.toDisplayString(b.value.showInfo(_)),1),b.value.showInfo(_)?(i.openBlock(),i.createBlock(V,{key:0,type:"link"},{default:i.withCtx(()=>p[50]||(p[50]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Qh)):["widget"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[_.name]||!Object.keys(s.value[_.name]).includes(B.dataIndex))&&!F&&"empty"]),onClick:D=>r(_,B.dataIndex)},[s.value[_.name]&&Object.keys(s.value[_.name]).includes(B.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(C,{key:0,value:_.configs?.widget?.name,allowClear:!0,options:k.value.widgets,onChange:D=>k.value.toSetting(_,D),onBlur:p[0]||(p[0]=D=>d())},null,8,["value","options","onChange"])),[[l]]):(i.openBlock(),i.createElementBlock("span",Xh,i.toDisplayString(k.value.widgetName(_)),1)),i.createVNode(V,{type:"link",onClick:i.withModifiers(D=>v(_),["stop"])},{default:i.withCtx(()=>p[51]||(p[51]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])],10,Yh)):["convertName"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[_.name]||!Object.keys(s.value[_.name]).includes(B.dataIndex))&&!_.convert?.type&&"empty"]),onClick:D=>O(_)},[_.configs?.convert?.types?(i.openBlock(),i.createElementBlock("span",Zh,i.toDisplayString(w.value.getTypes(_.configs.convert.types)),1)):i.createCommentVNode("",!0)],10,Jh)):["query","form","view","list","sort"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",ef,[i.createVNode(x,{checked:h(_,B.dataIndex),onClick:D=>f(_,B.dataIndex)},null,8,["checked","onClick"]),i.createVNode(V,{type:"link",onClick:D=>u(_,B.dataIndex)},{default:i.withCtx(()=>p[52]||(p[52]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(A,{visible:c.value.visible,"onUpdate:visible":p[14]||(p[14]=B=>c.value.visible=B),width:600,title:c.value.title,onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:c.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:i.normalizeClass(["field-setting-form","form-mix",c.value.prop])},{default:i.withCtx(()=>[i.createVNode(T,{label:"启用状态"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.enable,"onUpdate:checked":p[1]||(p[1]=B=>c.value.show.enable=B),checkedChildren:"启用",unCheckedChildren:"停用"},null,8,["checked"])]),_:1}),c.value.prop=="sort"?(i.openBlock(),i.createBlock(T,{key:0,label:"默认排序"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.defoult,"onUpdate:checked":p[2]||(p[2]=B=>c.value.show.defoult=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="sort"?(i.openBlock(),i.createBlock(T,{key:1,label:"排序方式"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.asc,"onUpdate:checked":p[3]||(p[3]=B=>c.value.show.asc=B),checkedChildren:"升序",unCheckedChildren:"降序"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"&&c.value.show.types=="ADVANCE"?(i.openBlock(),i.createBlock(T,{key:2,label:"高级查询"})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:3,label:"默认查询",tooltip:"开启后该字段加入关键字查询"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.defoult,"onUpdate:checked":p[4]||(p[4]=B=>c.value.show.defoult=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:4,label:"默认显示",tooltip:"开启后,在查询表单中默认显示该查询字段"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.visible,"onUpdate:checked":p[5]||(p[5]=B=>c.value.show.visible=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:5,label:"查询方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.types,"onUpdate:value":p[6]||(p[6]=B=>c.value.show.types=B)},{default:i.withCtx(()=>[i.createVNode(E,{key:"EQ",value:"EQ"},{default:i.withCtx(()=>p[53]||(p[53]=[i.createTextVNode("精确查询")])),_:1}),i.createVNode(E,{key:"LIKE",value:"LIKE"},{default:i.withCtx(()=>p[54]||(p[54]=[i.createTextVNode("模糊查询")])),_:1}),i.createVNode(E,{key:"LLIKE",value:"LLIKE"},{default:i.withCtx(()=>p[55]||(p[55]=[i.createTextVNode("左模糊")])),_:1}),i.createVNode(E,{key:"RLIKE",value:"RLIKE"},{default:i.withCtx(()=>p[56]||(p[56]=[i.createTextVNode("右模糊")])),_:1}),i.createVNode(E,{key:"RANGE",value:"RANGE"},{default:i.withCtx(()=>p[57]||(p[57]=[i.createTextVNode("范围查询")])),_:1}),i.createVNode(E,{key:"ADVANCE",value:"ADVANCE"},{default:i.withCtx(()=>p[58]||(p[58]=[i.createTextVNode("高级查询")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0),["query","sort"].includes(c.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(T,{key:6,label:"显示顺序",tooltip:"默认根据字段顺序显示,若需调整字段显示顺序,可以通过这里设置!"},{default:i.withCtx(()=>[i.createVNode(I,{value:c.value.show.index,"onUpdate:value":p[7]||(p[7]=B=>c.value.show.index=B)},null,8,["value"])]),_:1})),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:7,label:"显示宽度",tooltip:"字段显示宽度,0-24,设置成0,根据表单默认配置"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.width,"onUpdate:value":p[8]||(p[8]=B=>c.value.show.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:8,label:"显示宽度",tooltip:"字段显示宽度"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,value:c.value.show.width,"onUpdate:value":p[9]||(p[9]=B=>c.value.show.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:9,label:"标题宽度",tooltip:"表单title部分显示宽度,0-24"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.labelWidth,"onUpdate:value":p[10]||(p[10]=B=>c.value.show.labelWidth=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:10,label:"控件宽度",tooltip:"表单组件部分显示宽度,0-24"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.valueWidth,"onUpdate:value":p[11]||(p[11]=B=>c.value.show.valueWidth=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:11,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.fixed,"onUpdate:value":p[12]||(p[12]=B=>c.value.show.fixed=B),allowClear:"",options:[{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:12,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.align,"onUpdate:value":p[13]||(p[13]=B=>c.value.show.align=B),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model","class"])]),_:1},8,["visible","title","onOk"]),i.createVNode(A,{visible:w.value.visible,"onUpdate:visible":p[33]||(p[33]=B=>w.value.visible=B),width:600,title:w.value.getTypes(w.value.convert.types,"转换")+"设置",onOk:w.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:w.value.convert,name:"basic","label-col":{span:5},"wrapper-col":{span:17},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(T,{label:"转换类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:w.value.convert.types,"onUpdate:value":p[15]||(p[15]=B=>w.value.convert.types=B),allowClear:!0,options:w.value.types},null,8,["value","options"])]),_:1}),["unione-select-box","unione-tree-box"].includes(w.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:0,label:"是否搜索"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.convert.search,"onUpdate:checked":p[16]||(p[16]=B=>c.value.convert.search=B),checkedChildren:"启用",unCheckedChildren:"停用"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="option"?(i.openBlock(),i.createBlock(T,{key:1,label:"选项设置"},{default:i.withCtx(()=>[i.createVNode(V,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:w.value.toAddOption},{default:i.withCtx(()=>p[59]||(p[59]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(S,{columns:w.value.optionColumn,"data-source":w.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:B,record:F,index:_})=>[B.dataIndex==="label"?(i.openBlock(),i.createBlock(U,{key:0,value:F.label,"onUpdate:value":D=>F.label=D,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),B.dataIndex==="value"?(i.openBlock(),i.createBlock(U,{key:1,value:F.value,"onUpdate:value":D=>F.value=D,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),B.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:D=>w.value.toDelOption(_,F)},"删除",8,tf)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])]),_:1})):i.createCommentVNode("",!0),["dbtable","remote"].includes(w.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:2,label:"数据源"},{default:i.withCtx(()=>[i.createVNode(P,{value:w.value.convert.dsId,"onUpdate:value":p[17]||(p[17]=B=>w.value.convert.dsId=B),convert:{types:"local",url:"/api/data/source/find",search:!0}},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:3,label:"table名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableName,"onUpdate:value":p[18]||(p[18]=B=>w.value.convert.tableName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:4,label:"table名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableName,"onUpdate:value":p[19]||(p[19]=B=>w.value.convert.tableName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"&&["unione-tree-box"].includes(w.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:5,label:"主键字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.idField,"onUpdate:value":p[20]||(p[20]=B=>w.value.convert.idField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"&&["unione-tree-box"].includes(w.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:6,label:"父级字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.pidField,"onUpdate:value":p[21]||(p[21]=B=>w.value.convert.pidField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:7,label:"value字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.valueField,"onUpdate:value":p[22]||(p[22]=B=>w.value.convert.valueField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:8,label:"label字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.labelField,"onUpdate:value":p[23]||(p[23]=B=>w.value.convert.labelField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:9,label:"扩展字段",tooltip:"默认只加载value,label字段,可以通过该属性加载其他更多字段,多个字段用逗号分隔"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableField,"onUpdate:value":p[24]||(p[24]=B=>w.value.convert.tableField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:10,label:"数据过滤",tooltip:"支持数据条件过滤,eg:sex=1"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableWhere,"onUpdate:value":p[25]||(p[25]=B=>w.value.convert.tableWhere=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:11,label:"数据排序",tooltip:"设置数据进行排序方式,eg:age desc"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableOrder,"onUpdate:value":p[26]||(p[26]=B=>w.value.convert.tableOrder=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:12,label:"数据排序",tooltip:"设置数据进行排序方式,eg:age desc"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.tableOrder,"onUpdate:value":p[27]||(p[27]=B=>w.value.convert.tableOrder=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:13,label:"异步加载"},{default:i.withCtx(()=>[i.createVNode(M,{checked:w.value.convert.isAsync,"onUpdate:checked":p[28]||(p[28]=B=>w.value.convert.isAsync=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:14,label:"分页加载"},{default:i.withCtx(()=>[i.createVNode(M,{checked:w.value.convert.isPaging,"onUpdate:checked":p[29]||(p[29]=B=>w.value.convert.isPaging=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),w.value.convert.types=="dict"?(i.openBlock(),i.createBlock(T,{key:15,label:"字典名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.dictName,"onUpdate:value":p[30]||(p[30]=B=>w.value.convert.dictName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["local","remote"].includes(w.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:16,label:"接口地址",tooltip:"统一使用POST请求,json提交,标准结构:{body:{参数}}"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.convert.url,"onUpdate:value":p[31]||(p[31]=B=>w.value.convert.url=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["local","remote"].includes(w.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:17,label:"接口参数",tooltip:"标准json对象/数组,直接使用该参数进行接口请求,请求确保结构和接口匹配!"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:w.value.convert.params,"onUpdate:modelValue":p[32]||(p[32]=B=>w.value.convert.params=B),placeholder:"接口请求参数,eg:{sex:1}",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:e.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(A,{visible:k.value.visible,"onUpdate:visible":p[40]||(p[40]=B=>k.value.visible=B),width:600,title:"控件设置",onOk:k.value.toclose},{default:i.withCtx(()=>[i.createVNode(L,{model:k.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(T,{label:"组件类型"},{default:i.withCtx(()=>[i.withDirectives(i.createVNode(C,{value:k.value.widget.name,"onUpdate:value":p[34]||(p[34]=B=>k.value.widget.name=B),allowClear:!0,options:k.value.widgets},null,8,["value","options"]),[[l]])]),_:1}),i.createVNode(T,{label:"输入提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.widget.placeholder,"onUpdate:value":p[35]||(p[35]=B=>k.value.widget.placeholder=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"帮助说明"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.widget.help,"onUpdate:value":p[36]||(p[36]=B=>k.value.widget.help=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"提示文本"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.widget.tooltip,"onUpdate:value":p[37]||(p[37]=B=>k.value.widget.tooltip=B)},null,8,["value"])]),_:1}),["a-date-picker"].includes(k.value.widget.name)?(i.openBlock(),i.createBlock(T,{key:0,label:"显示格式"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.field.dataFormat,"onUpdate:value":p[38]||(p[38]=B=>k.value.field.dataFormat=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.widget.name=="unione-select-box"?(i.openBlock(),i.createBlock(T,{key:1,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:k.value.widget.props.mode,"onUpdate:value":p[39]||(p[39]=B=>k.value.widget.props.mode=B),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(E,{value:"multiple"},{default:i.withCtx(()=>p[60]||(p[60]=[i.createTextVNode("多选")])),_:1}),i.createVNode(E,{value:"tags"},{default:i.withCtx(()=>p[61]||(p[61]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(A,{visible:b.value.visible,"onUpdate:visible":p[49]||(p[49]=B=>b.value.visible=B),width:600,title:"规则设置",onOk:b.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:b.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(j,{title:"基本设置",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(G,{value:b.value.props.trigger,"onUpdate:value":p[41]||(p[41]=B=>b.value.props.trigger=B),options:["change","blur"]},null,8,["value"])]),_:1}),b.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(T,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(x,{checked:b.value.props.whitespace,"onUpdate:checked":p[42]||(p[42]=B=>b.value.props.whitespace=B)},{default:i.withCtx(()=>p[62]||(p[62]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["checked"])]),_:1})),i.createVNode(T,{label:"预设类型"},{default:i.withCtx(()=>[i.createVNode(C,{options:b.value.advances,fieldNames:{label:"title",value:"name"},value:b.value.props.advance,"onUpdate:value":p[43]||(p[43]=B=>b.value.props.advance=B)},null,8,["options","value"])]),_:1})]),_:1}),["Long","Short","Integer","Float","Double"].includes(b.value.field.dataType)?(i.openBlock(),i.createBlock(j,{key:0,title:"数值验证",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(I,{value:b.value.props.rangeMin,"onUpdate:value":p[44]||(p[44]=B=>b.value.props.rangeMin=B)},null,8,["value"]),p[63]||(p[63]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(I,{value:b.value.props.rangeMax,"onUpdate:value":p[45]||(p[45]=B=>b.value.props.rangeMax=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.rangeMessage,"onUpdate:value":p[46]||(p[46]=B=>b.value.props.rangeMessage=B)},null,8,["value"])]),_:1})]),_:1})):i.createCommentVNode("",!0),i.createVNode(j,{title:"正则验证",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.regExpress,"onUpdate:value":p[47]||(p[47]=B=>b.value.props.regExpress=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.regMessage,"onUpdate:value":p[48]||(p[48]=B=>b.value.props.regMessage=B)},null,8,["value"])]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-d5938ab8"]]),lf={class:"unione-props-setting data-field-fkey"},sf={key:0},of=["onClick"],af=["onClick"],rf=["onClick"],df=["onClick"],cf=["onClick"],hf=["onClick"],ff=["onClick"],uf=["onClick"],pf=ne(i.defineComponent({__name:"dataFieldFKeys",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=K.useDialog(),t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:u})=>u+1},{title:"字段名称",dataIndex:"name",key:"name",width:"100px",fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"100px",fixed:"left",align:"center"},{title:"关联数据名称",dataIndex:"dsnName",key:"dsnName",width:"120px",align:"center"},{title:"关联数据标题",dataIndex:"dsnTitle",key:"dsnTitle",width:"150px",align:"center"},{title:"关联字段",dataIndex:"fieldName",key:"fieldName",width:"100px",align:"center"},{title:"显示字段",dataIndex:"labelName",key:"labelName",width:"120px",align:"center"}]),n=i.useModel(o,"modelValue"),l=i.computed(()=>n.value.filter(u=>u.configs?.fkey?.enable)||[]),s=i.ref({});function a(){s.value={}}function r(u,m){a();const b={};b[m]=u.configs.fkey[m]||"",s.value[u.name]=b}function d(u,m,b){u.configs.fkey.dsn=m,u.configs.fkey.dsnName=b.name,u.configs.fkey.dsnTitle=b.title,u.configs.fkey.dsnId=b.id}function h(u,m,b,y){u.configs.fkey[m]=b,m=="fieldName"&&(u.configs.fkey.fieldTitle=y.title),m=="labelName"&&(u.configs.fkey.labelTitle=y.title)}function f(u){c.value.record=u,c.value.visible=!0,c.value.fields=u.configs?.fkey?.fields||[]}const c=i.ref({visible:!1,record:null,editField:{},fields:[],columns:[{title:"字段名称",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"显示宽度",dataIndex:"width",key:"width",width:"60px",align:"center"},{title:"显示顺序",dataIndex:"index",key:"index",width:"60px",align:"center"},{title:"操作",dataIndex:"action",key:"action",width:"60px",align:"center"}],toEditField:(u,m)=>{c.value.editField[u]=m},onShowFieldChange:(u,m,b)=>{u.name=b.name,u.title=b.title},toAddField:()=>{c.value.fields.push({name:"",title:""}),c.value.editField[c.value.fields.length-1]="title"},toDelField:u=>{e.confirm({content:"确定要删除该字段么?",onOk:()=>{c.value.fields.splice(u,1)}})},toSetting:()=>{c.value.visible=!1,c.value.record.configs=K.utils.obj.ext(c.value.record.configs,{fkey:{fields:c.value.fields}})}});return(u,m)=>{const b=i.resolveComponent("FormOutlined"),y=i.resolveComponent("unione-select-box"),k=i.resolveComponent("a-button"),v=i.resolveComponent("a-table"),w=i.resolveComponent("a-input-number"),O=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",lf,[i.createVNode(v,{columns:t.value,"data-source":l.value,bordered:"","row-key":"name",size:"small",pagination:!1},{headerCell:i.withCtx(({column:g})=>[["dsnName","dsnTitle","fieldName","labelName"].includes(g.key)?(i.openBlock(),i.createElementBlock("span",sf,[i.createVNode(b),i.createTextVNode(" "+i.toDisplayString(g.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:g,record:p})=>[["dsnName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[p.name]||!Object.keys(s.value[p.name]).includes(g.dataIndex))&&!p.configs?.fkey?.dsnName&&"empty"]),onClick:N=>r(p,g.dataIndex)},[s.value[p.name]&&Object.keys(s.value[p.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[p.name][g.dataIndex],"onUpdate:value":N=>s.value[p.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/define/find",valueField:"sn",labelField:"name",search:!0},onBlur:a,onSelect:(N,V)=>d(p,N,V)},null,8,["value","onUpdate:value","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(p.configs?.fkey?.dsnName),1)],64))],10,of)):["dsnTitle"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[p.name]||!Object.keys(s.value[p.name]).includes(g.dataIndex))&&!p.configs?.fkey?.dsnTitle&&"empty"]),onClick:N=>r(p,g.dataIndex)},[s.value[p.name]&&Object.keys(s.value[p.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[p.name][g.dataIndex],"onUpdate:value":N=>s.value[p.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/define/find",valueField:"sn",labelField:"title",search:!0},onBlur:a,onSelect:(N,V)=>d(p,N,V)},null,8,["value","onUpdate:value","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(p.configs?.fkey?.dsnTitle),1)],64))],10,af)):i.createCommentVNode("",!0),["fieldName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[p.name]||!Object.keys(s.value[p.name]).includes(g.dataIndex))&&!p.configs?.fkey?.fieldName&&"empty"]),onClick:N=>r(p,g.dataIndex)},[s.value[p.name]&&p.configs?.fkey?.dsn&&Object.keys(s.value[p.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[p.name][g.dataIndex],"onUpdate:value":N=>s.value[p.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/field/find",params:{body:{defineId:p.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:a,onSelect:(N,V)=>h(p,"fieldName",N,V)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(p.configs?.fkey?.fieldTitle),1)],64))],10,rf)):["labelName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:3,class:i.normalizeClass(["edit-field",(!s.value[p.name]||!Object.keys(s.value[p.name]).includes(g.dataIndex))&&!p.configs?.fkey?.labelName&&"empty"]),onClick:N=>r(p,g.dataIndex)},[s.value[p.name]&&p.configs?.fkey?.dsn&&Object.keys(s.value[p.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[p.name][g.dataIndex],"onUpdate:value":N=>s.value[p.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/field/find",params:{body:{defineId:p.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:a,onSelect:(N,V)=>h(p,"labelName",N,V)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(p.configs?.fkey?.labelTitle)+" ",1),p.configs?.fkey?.labelName?(i.openBlock(),i.createBlock(k,{key:0,type:"link",onClick:i.withModifiers(N=>f(p),["stop"])},{default:i.withCtx(()=>m[4]||(m[4]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,df)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(O,{visible:c.value.visible,"onUpdate:visible":m[3]||(m[3]=g=>c.value.visible=g),width:600,title:"更多显示字段",class:"data-field-fkey",onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(k,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:c.value.toAddField},{default:i.withCtx(()=>m[5]||(m[5]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(v,{columns:c.value.columns,"data-source":c.value.fields,size:"small"},{bodyCell:i.withCtx(({column:g,record:p,index:N,text:V})=>[g.dataIndex==="title"?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",c.value.editField!="title"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="title"?(i.openBlock(),i.createBlock(y,{key:0,value:p[p.dataIndex],"onUpdate:value":C=>p[p.dataIndex]=C,convert:{types:"local",url:"/api/data/field/find",search:!0,params:{body:{defineId:c.value.record.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:m[0]||(m[0]=C=>c.value.editField={}),onSelect:(C,x)=>c.value.onShowFieldChange(p,C,x)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,cf)):i.createCommentVNode("",!0),g.dataIndex==="width"?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",c.value.editField!="width"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="width"?(i.openBlock(),i.createBlock(w,{key:0,onBlur:m[1]||(m[1]=C=>c.value.editField={}),value:p.width,"onUpdate:value":C=>p.width=C,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,hf)):i.createCommentVNode("",!0),g.dataIndex==="index"?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",c.value.editField!="wiindexdth"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="index"?(i.openBlock(),i.createBlock(w,{key:0,onBlur:m[2]||(m[2]=C=>c.value.editField={}),value:p.index,"onUpdate:value":C=>p.index=C,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,ff)):i.createCommentVNode("",!0),g.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:3,onClick:C=>c.value.toDelField(N)},"删除",8,uf)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-84143692"]]),mf={class:"unione-props-setting data-filter"},gf={class:"title"},kf={class:"name"},bf={class:"action"},yf=ne(i.defineComponent({__name:"dataFilters",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=K.useDialog(),t=i.useModel(o,"modelValue");function n(){r.value.visible=!0,r.value.filter={},r.value.name=null}function l(h){r.value.visible=!0,r.value.filter={...h},r.value.name=h.name}function s(h){e.confirm({content:"确定要删除该过滤对象么?",onOk:()=>{t.value.splice(h,1)}})}const a=i.ref(),r=i.ref({visible:!1,name:null,filter:{},rules:{title:[{required:!0,message:"过滤标题不能为空"}],name:[{required:!0,message:"过滤名称不能为空"}],filter:[{required:!0,message:"过滤脚本不能为空"}]},toSetting:()=>{a.value.validate().then(h=>{if(r.value.name){const f=t.value.filter(c=>c.name==r.value.name)[0];if(!f){e.error({content:"过滤记录未找到"});return}if(r.value.name!=r.value.filter.name&&t.value.filter(u=>u.name==r.value.filter.name).length){e.error({content:"过滤名称已存在!"});return}Object.keys(h).forEach(c=>{f[c]=h[c]})}else{if(t.value.filter(c=>c.name==r.value.filter.name).length){e.error({content:"过滤名称已存在!"});return}t.value.push(h)}r.value.visible=!1})}});function d(){const h=[];r.value.filter.filter||(r.value.filter.filter=""),h.push("-- @if(isNotEmpty(params."),h.push(r.value.filter.name||"xxx"),h.push(") && !isBlank(params."),h.push(r.value.filter.name||"xxx"),h.push(`)
1
+ (function(ee,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("unione-base-vue"),require("vue"),require("ant-design-vue"),require("lodash-es"),require("vue-codemirror"),require("@codemirror/lang-javascript"),require("@ant-design/icons-vue"),require("uuid")):typeof define=="function"&&define.amd?define(["exports","unione-base-vue","vue","ant-design-vue","lodash-es","vue-codemirror","@codemirror/lang-javascript","@ant-design/icons-vue","uuid"],K):(ee=typeof globalThis<"u"?globalThis:ee||self,K(ee.index={},ee.UnioneBaseVue,ee.Vue,ee.antDesignVue,ee.lodashEs,ee.vueCodemirror,ee.langJavascript,ee.iconsVue,ee.uuid))})(this,function(ee,K,i,J,na,Lt,la,He,sa){"use strict";const oa={isDebug:!0,axios:{form:"/portal"},listPageUrl:"/unione/page/list",addPageUrl:"/unione/page/add",editPageUrl:"/unione/page/edit",viewPageUrl:"/unione/page/view",formRules:[]},Ji=i.ref(oa);function Ie(a){return a&&(Ji.value=K.utils.obj.ext(Ji.value,a)),Ji.value}const aa={...{...{submit:"提交","submit.ok":"已提交","submit.error":"提交失败","confirm.ok":"确定","confirm.cancel":"取消","global.setting.title":"设置"},...{"pages.home":"首页"},...{"pages.layouts.userLayout.title":"user layout"}}},ra={...{submit:"Submit","submit.ok":"Submitted","submit.error":"Submit Failed","confirm.ok":"Yes","confirm.cancel":"No","global.setting.title":"Settings"},...{"pages.home":"Home"},...{"pages.layouts.userLayout.title":"user layout"}},da=i.ref([aa,ra]);function ca(a,e){return K.locales.loadLanguage(a,()=>new Promise((t,n)=>{const l=da.value.filter(s=>s.localeName==a);if(e)if(typeof e=="function")e().then(s=>{if(l.length==0){const o={...s,localeName:a};t(o)}else{const o={...l[0],...s};t(o)}});else if(l.length==0){const s={...e,localeName:a};t(s)}else{const s={...l[0],...e};t(s)}else l.length>0?t(l[0]):n("local language not defined ,lang:"+a)}))}const Zi={...K.locales};Zi.loadLanguage=ca;class ha{$psn;$pid;$store;$forms;$model;$params;$refObj;$refData;constructor(e,t){this.$psn=i.ref(e),this.$pid=i.ref(""),this.$store=i.ref({}),this.$forms=i.ref({}),this.$params=i.ref({}),this.$refObj=i.ref({}),this.$refData=i.ref({}),this.$model=t}params(e){if(e){this.$params.value=e,e.id&&(this.$pid.value=e.id,this.$psn.value&&this.use(this.$psn.value,"form").detail(this.$pid.value));for(const t in this.$store.value)this.$store.value[t].$params=e}return this.$params.value}psn(e){return e&&(this.$psn.value=e),this.$psn.value}regRef(e,t){}setRefData(e,t,n){}use(e,t,n){let l=this.$store.value[e];return l||(l=new en(e,t,this.$model),this.$store.value[e]=l,l.$params=this.$params.value),n&&(l.$form=n,this.$forms.value[e]=n),l}useForm(e,t,n){const l=this.use(e,"form",t);return this.$psn.value==e&&this.$pid.value&&l.detail(this.$pid.value).then(s=>{n&&n(s)}),l}data(e){return this.$store.value[e]}form(e){return e?this.$forms.value[e]:this.$forms.value}primary(){return this.data(this.$psn.value)}dsnList(){return Object.keys(this.$store.value)}}class en{$dsn;$type;$data;$dialog;$model;$form;$params;$store;constructor(e,t,n){typeof e=="string"?(this.$dsn=e,this.$store={controller:"/api/data/storage/v1"}):(this.$store=e,this.$dsn=""),this.$type=t,this.$data=i.ref(t=="form"?{}:{body:[],total:0}),this.$dialog=K.useDialog(),this.$model=n||i.ref("run")}$isStorage(){return this.$store.controller.indexOf("/api/data/storage")>=0}store(e){return e&&(this.$store=e),this.$store}data(){return this.$type=="form"?this.$data.value||{}:this.$data.value||[]}setValue(e){this.$data.value=e,this.$form?.setValue(e)}$processParams(e,t){if(t)t.forEach(n=>{e[n.name]==null&&e[n.name]==null&&(this.$params[n.name]!=null&&this.$params[n.name]!=null?e[n.alias||n.name]=this.$params[n.name]:n.value!=null&&n.value!=null&&(e[n.alias||n.name]=n.value))});else if(this.$params)for(const n in this.$params)e[n]==null&&e[n]==null&&this.$params[n]!=null&&this.$params[n]!=null&&(e[n]=this.$params[n]);return e}request(e){return new Promise((t,n)=>{const l=J.message.loading("数据请求中..."),s=this.$store.controller+e.url;K.axios.form({method:"post",...e,url:s}).then(o=>{o.success?t(o):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),n({info:"数据请求失败,model sn:"+this.$dsn+",url:"+s,options:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据请求失败,model sn:"+this.$dsn+",url:"+s,options:e,err:o})}).finally(()=>{l()})})}find(e){const t=this.$store.controller+(this.$store.findUrl||"/find");return!e&&this.$store.findParams&&(e={dsn:this.$dsn}),this.$isStorage()&&(e.dsn=this.$dsn+(this.$model!="run"?"@dev":"")),e&&(e.body=this.$processParams(e.body,this.$store.findParams)),new Promise((n,l)=>{const s=J.message.loading("数据加载中...");K.axios.form({url:t,method:"post",data:e}).then(o=>{o.success?(this.$data.value=o,n(o)):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),l({info:"数据加载失败,model sn:"+this.$dsn,url:t,params:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),l({info:"数据加载失败,model sn:"+this.$dsn,url:t,params:e,err:o})}).finally(()=>{s()})})}save(e){const t=this.$store.controller+(this.$store.saveUrl||"/save");return this.$isStorage()?(e.dsn=this.$dsn+(this.$model!="run"?"@dev":""),e.params=this.$processParams(e.params,this.$store.saveParams)):e.data=this.$processParams(e.data,this.$store.saveParams),new Promise((n,l)=>{const s=J.message.loading("数据提交中...");K.axios.form({url:t,method:"post",data:this.$isStorage()?e:e.data}).then(o=>{o.success?(this.$type=="form"&&(this.$data.value=o.body||{}),o.silence||J.message.success(o.message),n(o)):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),l({info:"数据保存失败,model sn:"+this.$dsn,url:t,data:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),l({info:"数据保存失败,model sn:"+this.$dsn,url:t,data:e,err:o})}).finally(()=>{s()})})}loadByIds(e){return new Promise((t,n)=>{const l=J.message.loading("数据加载中..."),s=this.$store.controller+"/loadByIds";K.axios.form({url:s,method:"post",data:this.$isStorage()?{ids:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(o=>{o.success?t(o):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),n({info:"数据加载失败,model sn:"+this.$dsn,ids:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据加载失败,model sn:"+this.$dsn,ids:e,err:o})}).finally(()=>{l()})})}detail(e){return new Promise((t,n)=>{const l=J.message.loading("数据加载中..."),s=this.$store.controller+"/detail";K.axios.form({url:s,method:"post",data:this.$isStorage()?{id:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(o=>{o.success?(this.$type=="form"&&(this.$data.value=o.body),t(o)):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),n({info:"加载数据详情失败,model sn:"+this.$dsn,url:s,id:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"加载数据详情失败,model sn:"+this.$dsn,url:s,id:e,err:o})}).finally(()=>{l()})})}deleteByIds(e){return new Promise((t,n)=>{this.$dialog.confirm({content:"确定要删除选中记录么?共"+e.length+"条。",onOk:()=>{const l=J.message.loading("数据处理中..."),s=this.$store.controller+"/delete";K.axios.form({url:s,method:"post",data:this.$isStorage()?{ids:e,dsn:this.$dsn+(this.$model!="run"?"@dev":"")}:e}).then(o=>{o.success?t(o):(o.silence||this.$dialog.error({content:o.message||"未知错误,请联系管理员"}),n({info:"数据删除失败,model sn:"+this.$dsn,url:s,ids:e,result:o}))}).catch(o=>{this.$dialog.error({content:"未知错误,请联系管理员"}),n({info:"数据删除失败,model sn:"+this.$dsn,url:s,ids:e,err:o})}).finally(()=>{l()})}})})}}class fa{$event;$onces;$delayEmit;constructor(){this.$event=i.ref({}),this.$onces=i.ref({}),this.$delayEmit=i.ref({})}$on(e,t){if(this.$event.value[e]=t,this.$delayEmit.value[e]){const n=this.$delayEmit.value[e];t(n)}}$emit(e,t){if(this.$onces.value[e]){const n=this.$onces.value[e];delete this.$onces.value[e],n(t)}this.$event.value[e]?this.$event.value[e](t):(this.$delayEmit.value[e]=t,setTimeout(()=>{delete this.$delayEmit.value[e]},1e3*10))}$once(e,t){this.$onces.value[e]=t}$off(e){delete this.$event.value[e]}}class ct{define;ebus;model;type;$widgetList;$widgetMap;$dataManager;$axiosProccess;$dialog;constructor(e={sn:"new_",title:"新建页面",types:"setting",vers:1,configs:{widgets:[],dsnList:[]}}){const t=e.configs||{};this.model=i.ref("run"),this.type=i.ref(e.types||"setting"),this.define=i.ref(e),this.ebus=new fa,this.$widgetList=i.ref([]),this.$widgetMap=i.ref({}),this.$dataManager=new ha(t.dsnList?t.dsnList[0]:"",this.model),this.$axiosProccess=i.ref({}),this.$dialog=K.useDialog(),this.loadConfig(t)}sn(){return this.define.value.sn}load(e,t){if(!e)return;if(this.define.value.sn=e,e=="new_"){console.log("新建/本地页面sn:"+e+",define:",t),t&&t.configs&&(this.define.value=t,this.type.value=this.define.value.types||"setting",this.loadConfig(t.configs));return}const n=sessionStorage.getItem("PAGE_DEFINE:"+e);if(n&&this.model.value=="run"){this.define.value=JSON.parse(n),this.type.value=this.define.value.types||"setting",this.loadConfig(this.define.value.configs),console.log("从会话缓存中加载页面sn:"+e+",define:",this.define.value);return}K.axios.form({url:"/api/page/define/load/"+e,method:"post"}).then(l=>{l.success?(this.define.value=l.body,this.type.value=this.define.value.types||"setting",l.body.configs?this.define.value.configs=l.body.configs:this.define.value.configs={widgets:[],dsnList:[]},this.loadConfig(this.define.value.configs),sessionStorage.setItem("PAGE_DEFINE:"+e,JSON.stringify(this.define.value)),console.log("从远程服务加载页面sn:"+e+",define:",this.define.value)):t&&t.configs&&(this.define.value=t,this.loadConfig(t.configs))})}save(){return new Promise((e,t)=>{if(this.$axiosProccess.value.save){console.warn("unione form editor save process runing,sn:"+this.define.value.sn),t();return}this.$axiosProccess.value.save=!0;const n={...this.define.value.configs||{},widgets:this.$widgetList.value,dsnList:this.$dataManager.dsnList()},l={...this.define.value};l.configs=JSON.stringify(n),K.axios.form({url:"/api/page/define/save",method:"post",data:l}).then(s=>{this.$axiosProccess.value.save=!1,s.success?(J.message.success(s.message),this.define.value=s.body,sessionStorage.setItem("PAGE_DEFINE:"+this.define.value.sn,JSON.stringify(this.define.value)),this.load(this.define.value.sn,this.define.value),e(s.body)):(this.$dialog.error({content:s.message}),t())}).catch(s=>{console.error("页面配置保存失败",s),this.$dialog.error({content:"页面配置保存失败"})}).finally(()=>{this.$axiosProccess.value.save=!1})})}loadConfig(e){e.dsnList?.length&&this.$dataManager.psn(e.dsnList[0]),this.$widgetList.value=e.widgets||[],this.$widgetMap.value={},this.$processWidget(this.$widgetList.value)}setModel(e){this.model.value=e}widget(e,t){if(t){const n={...t,wid:e};this.$widgetMap.value[e]||(this.$widgetList.value.push(n),n.configs?.widgets&&this.$processWidget(n.configs.widgets)),this.$widgetMap.value[e]=n}else return this.$widgetMap.value[e]}widgets(e){if(e)this.$widgetList.value=e,this.$widgetMap.value={},this.$processWidget(e);else return this.$widgetList.value}$processWidget(e){e.forEach(t=>{t.wid||(t.wid="w:"+na.uniqueId()),this.$widgetMap.value[t.wid]=t,t.configs?.widgets&&this.$processWidget(t.configs.widgets)})}dataManager(){return this.$dataManager}}const ua={class:"widget-setting-dialog"},pa=i.defineComponent({__name:"widget",props:{model:{type:String,required:!1},settingTitle:{type:String,default:"组件设置"},custome:{type:Boolean,default:!1}},emits:["setting","saving"],setup(a,{emit:e}){const t=e,n=i.ref(),l=i.ref(!1);function s(){n.value&&(l.value=!0),t("setting")}function o(){t("saving"),l.value=!1}return(r,d)=>{const h=i.resolveComponent("SettingOutlined"),f=i.resolveComponent("a-tooltip"),c=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-widget",a.model])},[i.createVNode(f,{title:a.settingTitle},{default:i.withCtx(()=>[a.model=="edit"&&(r.$slots["widget-setting"]||a.custome)?(i.openBlock(),i.createBlock(h,{key:0,class:"widget-setting",onClick:s})):i.createCommentVNode("",!0)]),_:1},8,["title"]),i.renderSlot(r.$slots,"default",{},void 0,!0),a.model=="edit"&&r.$slots["widget-setting"]?(i.openBlock(),i.createBlock(c,{key:0,title:a.settingTitle,ref_key:"settingModal",ref:n,open:l.value,"onUpdate:open":d[0]||(d[0]=p=>l.value=p),centered:"",width:"80%",onOk:o},{default:i.withCtx(()=>[i.createElementVNode("div",ua,[i.renderSlot(r.$slots,"widget-setting",{},void 0,!0)])]),_:3},8,["title","open"])):i.createCommentVNode("",!0)],2)}}}),ne=(a,e)=>{const t=a.__vccOpts||a;for(const[n,l]of e)t[n]=l;return t},ht=ne(pa,[["__scopeId","data-v-3a88c0c0"]]),ma={key:0},ga=["onClick"],ci=ne(i.defineComponent({__name:"btnSetting",props:{preset:{type:Array,default(){return[]}}},setup(a,{expose:e}){const t=a,n=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:g})=>g+1},{title:"参数名称",dataIndex:"name",key:"name",width:"60px",align:"center"},{title:"参数标题",dataIndex:"title",key:"title",width:"80px",align:"center"},{title:"参数value",dataIndex:"value",key:"value",width:"100px",align:"center"}]),l=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:g=>{l.value.selectedRowKeys=g}}),s={mounted:g=>g.focus()},o=i.ref({});function r(){const g=Object.keys(o.value);if(g.length)for(let u in g){const N=y.value.form.action.params[u];N&&o.value[u]&&Object.keys(o.value[u]).forEach(V=>{N[V]=o.value[u][V]})}o.value={}}function d(g,u,N){r();const V={};V[N]=u[N]||"",N=="showIndex"&&(V[N]=u.show?.query?.index),o.value[g]=V}function h(g,u,N){if(!u||!N){o.value={};return}const V=o.value[g][N];u[N]=V,o.value={}}function f(){y.value.form.action.params.push({title:"新建",name:"",value:""})}function c(){}const p=i.ref(""),m=i.ref({title:[{required:!0,message:"按钮标题不能为空"}],name:[{required:!0,message:"按钮名称不能为空"},{validator:(g,u)=>p.value!=u&&t.preset.includes(u)?Promise.reject("预设按钮名称,请使用其他名称,["+t.preset.join(",")+"]"):Promise.resolve(),trigger:"change"}]}),b=i.ref([la.javascript()]),y=i.ref({title:"按钮设置",visible:!1,form:{},helps:{}}),w=i.ref();function v(g,u,N={}){g=JSON.parse(JSON.stringify(g)),g.event||(g.event={}),g.props||(g.props={}),g.action||(g.action={}),Object.keys(g.action).includes("maskClosable")||(g.action.maskClosable=!0),g.action.params||(g.action.params=[]),p.value=g.name,y.value.form=g,y.value.helps=N,y.value.visible=!0,w.value=u}const k=i.ref(null);function O(){k.value&&k.value.validate().then(()=>{y.value.visible=!1,w.value(y.value.form)})}return e({open:v,close}),(g,u)=>{const N=i.resolveComponent("a-input"),V=i.resolveComponent("a-form-item"),C=i.resolveComponent("a-select"),x=i.resolveComponent("a-input-number"),S=i.resolveComponent("a-checkbox"),M=i.resolveComponent("a-tab-pane"),T=i.resolveComponent("a-switch"),E=i.resolveComponent("a-button"),I=i.resolveComponent("a-divider"),L=i.resolveComponent("ToolOutlined"),A=i.resolveComponent("a-tooltip"),U=i.resolveComponent("a-table"),P=i.resolveComponent("a-tabs"),G=i.resolveComponent("a-form"),j=i.resolveComponent("a-modal");return i.openBlock(),i.createBlock(j,{visible:y.value.visible,"onUpdate:visible":u[23]||(u[23]=B=>y.value.visible=B),title:y.value.title,centered:"",width:"50%",onOk:O},{default:i.withCtx(()=>[i.createVNode(G,{name:"basic",ref_key:"form",ref:k,rules:m.value,model:y.value.form,"label-col":{span:5},"wrapper-col":{span:19},autocomplete:"off",class:"form-mix btn-setting-form"},{default:i.withCtx(()=>[i.createVNode(P,null,{default:i.withCtx(()=>[i.createVNode(M,{key:"base",tab:"基本设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"操作标题",required:"",name:"title"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.title,"onUpdate:value":u[0]||(u[0]=B=>y.value.form.title=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"操作名称",name:"name",required:""},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.name,"onUpdate:value":u[1]||(u[1]=B=>y.value.form.name=B),disabled:t.preset.includes(y.value.form.name)},null,8,["value","disabled"])]),_:1}),i.createVNode(V,{label:"操作图标"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.icon,"onUpdate:value":u[2]||(u[2]=B=>y.value.form.icon=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.type,"onUpdate:value":u[3]||(u[3]=B=>y.value.form.type=B),allowClear:"",options:[{value:"primary",label:"主要按钮"},{value:"ghost",label:"幽灵按钮"},{value:"dashed",label:"虚线按钮"},{value:"link",label:"连接按钮"},{value:"text",label:"文本按钮"},{value:"default",label:"默认按钮"}]},null,8,["value"])]),_:1}),i.createVNode(V,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.index,"onUpdate:value":u[4]||(u[4]=B=>y.value.form.index=B)},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮大小"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.size,"onUpdate:value":u[5]||(u[5]=B=>y.value.form.size=B),options:[{value:"small",label:"小"},{value:"middle",label:"中"},{value:"large",label:"大"}]},null,8,["value"])]),_:1}),i.createVNode(V,{label:"按钮特性"},{default:i.withCtx(()=>[i.createVNode(S,{checked:y.value.form.props.block,"onUpdate:checked":u[6]||(u[6]=B=>y.value.form.props.block=B)},{default:i.withCtx(()=>u[24]||(u[24]=[i.createTextVNode("自适应 ")])),_:1},8,["checked"]),i.createVNode(S,{checked:y.value.form.props.danger,"onUpdate:checked":u[7]||(u[7]=B=>y.value.form.props.danger=B)},{default:i.withCtx(()=>u[25]||(u[25]=[i.createTextVNode("危险 ")])),_:1},8,["checked"]),i.createVNode(S,{checked:y.value.form.props.ghost,"onUpdate:checked":u[8]||(u[8]=B=>y.value.form.props.ghost=B)},{default:i.withCtx(()=>u[26]||(u[26]=[i.createTextVNode("幽灵 ")])),_:1},8,["checked"])]),_:1})]),_:1}),i.createVNode(M,{key:"action",tab:"响应设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"响应方式",required:""},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.type,"onUpdate:value":u[9]||(u[9]=B=>y.value.form.action.type=B),options:[{value:"link",label:"连接"},{value:"route",label:"路由"},{value:"drawer",label:"抽屉"},{value:"dialog",label:"对话框"}]},null,8,["value"])]),_:1}),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:0,label:"页面编码",help:"根据该页面编码渲染页面内容"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.psn,"onUpdate:value":u[10]||(u[10]=B=>y.value.form.action.psn=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:1,label:"组件名称",help:"组件方式渲染,Vue全局注册的组件名称,且监听params参数,psn参数"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.component,"onUpdate:value":u[11]||(u[11]=B=>y.value.form.action.component=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),i.createVNode(V,{label:"连接地址"},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.href,"onUpdate:value":u[12]||(u[12]=B=>y.value.form.action.href=B)},null,8,["value"])]),_:1}),["link","route"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:2,label:"连接方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.target,"onUpdate:value":u[13]||(u[13]=B=>y.value.form.action.target=B),options:[{value:"_blank",label:"新卡片页"},{value:"_self",label:"当前页面"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:3,label:"抽屉位置"},{default:i.withCtx(()=>[i.createVNode(C,{value:y.value.form.action.position,"onUpdate:value":u[14]||(u[14]=B=>y.value.form.action.position=B),options:[{value:"left",label:"左侧"},{value:"right",label:"右侧"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:4,label:"显示标题",required:""},{default:i.withCtx(()=>[i.createVNode(N,{value:y.value.form.action.title,"onUpdate:value":u[15]||(u[15]=B=>y.value.form.action.title=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:5,label:"蒙层关闭"},{default:i.withCtx(()=>[i.createVNode(T,{checked:y.value.form.action.maskClosable,"onUpdate:checked":u[16]||(u[16]=B=>y.value.form.action.maskClosable=B),"checked-children":"开","un-checked-children":"关"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),["drawer","dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:6,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.action.width,"onUpdate:value":u[17]||(u[17]=B=>y.value.form.action.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["dialog"].includes(y.value.form.action.type)?(i.openBlock(),i.createBlock(V,{key:7,label:"显示高度"},{default:i.withCtx(()=>[i.createVNode(x,{value:y.value.form.action.height,"onUpdate:value":u[18]||(u[18]=B=>y.value.form.action.height=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),i.createVNode(I,{orientation:"left"},{default:i.withCtx(()=>[u[29]||(u[29]=i.createTextVNode("参数列表 ")),i.createVNode(E,{size:"small",class:"param-btn",onClick:f},{default:i.withCtx(()=>u[27]||(u[27]=[i.createTextVNode("添加")])),_:1}),i.createVNode(E,{size:"small",class:"param-btn",danger:"",onClick:c},{default:i.withCtx(()=>u[28]||(u[28]=[i.createTextVNode("删除")])),_:1})]),_:1}),i.createVNode(U,{columns:n.value,"data-source":y.value.form.action.params,bordered:"",pagination:!1,"row-selection":l.value,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:B})=>[["name","title"].includes(B.key)?(i.openBlock(),i.createElementBlock("span",ma,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(B.title),1)])):i.createCommentVNode("",!0),["value"].includes(B.key)?(i.openBlock(),i.createBlock(A,{key:1,title:"支持常量和变量,变量使用{row.属性}方式获取"},{default:i.withCtx(()=>[i.createElementVNode("span",null,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(B.title),1)])]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:B,text:F,record:_,index:D})=>[["name","title","value"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!o.value[D]||!Object.keys(o.value[D]).includes(B.dataIndex))&&!F&&"empty"]),onClick:$=>d(D,_,B.dataIndex)},[o.value[D]&&Object.keys(o.value[D]).includes(B.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(N,{key:0,value:o.value[D][B.dataIndex],"onUpdate:value":$=>o.value[D][B.dataIndex]=$,onBlur:$=>h(D,_,B.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[s]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(F),1)],64))],10,ga)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])]),_:1}),i.createVNode(M,{key:"event",tab:"事件设置"},{default:i.withCtx(()=>[i.createVNode(V,{label:"点击事件",help:y.value.helps.clickScript||"点击事件处理脚本,上下文参数:ctx,当前按钮对象:btn,当前事件对象:event,返回false则不触发默认逻辑"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.clickScript,"onUpdate:modelValue":u[19]||(u[19]=B=>y.value.form.event.clickScript=B),placeholder:"请输入点击事件处理脚本",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"禁用逻辑",help:y.value.helps.disableScript||"按钮禁用逻辑控制脚本,上下文参数:ctx,当前按钮对象:btn,返回true禁用,否则可用"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.disableScript,"onUpdate:modelValue":u[20]||(u[20]=B=>y.value.form.event.disableScript=B),placeholder:"请输入按钮禁用逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"显示逻辑",help:y.value.helps.visibleScript||"按钮显示逻辑控制脚本,上下文参数:ctx,当前按钮对象:btn,返回false隐藏,否则可见"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.visibleScript,"onUpdate:modelValue":u[21]||(u[21]=B=>y.value.form.event.visibleScript=B),placeholder:"请输入按钮显示逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"]),i.createVNode(V,{label:"动态标题",help:y.value.helps.titleScript||"按钮显示标题控制脚本,上下文参数:ctx,当前按钮对象:btn"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:y.value.form.event.titleScript,"onUpdate:modelValue":u[22]||(u[22]=B=>y.value.form.event.titleScript=B),placeholder:"请输入按钮动态标题逻辑",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:b.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1},8,["help"])]),_:1})]),_:1})]),_:1},8,["rules","model"])]),_:1},8,["visible","title"])}}}),[["__scopeId","data-v-75055a2b"]]),ka=["src"],ba=["src"],ya=ne(i.defineComponent({__name:"btn",props:{editor:{type:Object,required:!1},disabled:{type:Boolean,default:!1},type:{type:String},widget:{type:Object,required:!0,default(){return{}}},preset:{type:Array,default(){return[]}},ctx:{type:Object,default(){return{}}}},emits:["click"],setup(a,{emit:e}){const t=Ie(),n=a,l=K.useSession();i.watch(()=>n.widget?.event,()=>{o()}),i.onMounted(()=>{o()});const s=i.ref({});function o(){n.widget?.event&&(n.widget.event.clickScript?s.value.click=new Function("ctx","btn","event",n.widget.event.clickScript):n.widget.event.click&&(s.value.click=n.widget.event.click),n.widget.event.disableScript?s.value.disable=new Function("ctx","btn",n.widget.event.disableScript):n.widget.event.disable&&(s.value.disable=n.widget.event.disable),n.widget.event.visibleScript?s.value.visible=new Function("ctx","btn",n.widget.event.visibleScript):n.widget.event.visible&&(s.value.visible=n.widget.event.visible),n.widget.event.titleScript?s.value.title=new Function("ctx","btn",n.widget.event.titleScript):n.widget.event.title&&(s.value.title=n.widget.event.title)),typeof n.widget.click=="function"&&(s.value.click=n.widget.click),typeof n.widget.title=="function"&&(s.value.title=n.widget.title),typeof n.widget.visible=="function"&&(s.value.visible=n.widget.visible),typeof n.widget.disabled=="function"&&(s.value.disable=n.widget.disabled)}const r=i.computed(()=>s.value.title?s.value.title(p.value,n.widget):n.widget.title),d=i.computed(()=>s.value.visible?s.value.visible(p.value,n.widget)!=!1:n.widget.visible!=!1),h=i.computed(()=>n.disabled==!0?!0:s.value.disable?s.value.disable(p.value,n.widget):n.widget.disable==!0),f=i.ref(null);function c(){f.value?.open(n.widget,g=>{console.log("btn props",g),Object.keys(g).forEach(u=>{n.widget[u]=g[u]}),console.log("props btn",n.widget)})}const p=i.computed(()=>({...n.ctx,user:l.getPrincipal(),token:l.getToken()})),m=i.ref({open:!1}),b=i.computed(()=>{if(n.widget.action?.href){let g=n.widget.action.href;const u=g.matchAll("{[a-zA-Z.]*}"),N=[];let V=null;for(;V=u.next();){if(V&&V.value&&V.value[0]){let C=V.value[0].substring(1,V.value[0].length-1);N.includes(C)||N.push(C)}if(V.done)break}if(N.length>0)for(let C=0;C<N.length;C++){let x=N[C],S=K.utils.obj.getValue(p.value,x);S?S instanceof Object?g=g.replaceAll("{"+x+"}",JSON.stringify(S)):Array.isArray(S)?g=g.replaceAll("{"+x+"}",S.join(",")):g=g.replaceAll("{"+x+"}",S):g=g.replaceAll("{"+x+"}","")}return g}return""}),y=i.computed(()=>{const g={};let u=n.widget.action?.href||n.widget.action?.link;if(u){const N=u.matchAll("{[a-zA-Z0-9.]*}"),V=[];let C=null;for(;C=N.next();){if(C&&C.value&&C.value[0]){let S=C.value[0].substring(1,C.value[0].length-1);V.includes(S)||V.push(S)}if(C.done)break}if(V.length>0)for(let S=0;S<V.length;S++){let M=V[S],T=K.utils.obj.getValue(p.value,M);T?T instanceof Object?u=u.replaceAll("{"+M+"}",JSON.stringify(T)):Array.isArray(T)?u=u.replaceAll("{"+M+"}",T.join(",")):u=u.replaceAll("{"+M+"}",T):u=u.replaceAll("{"+M+"}","")}const x=u.split("?")[1];x&&x.split("&").forEach(S=>{const M=S.split("=");M[0]&&M[1]&&(g[M[0]]=M[1])})}return n.widget.action?.params&&n.widget.action.params.filter(N=>N.value+"").forEach(N=>{if(new RegExp("{[a-zA-Z0-9.]*}").test(N.value)){let C=K.utils.obj.getValue(p.value,N.value);g[N.name]=C}else g[N.name]=N.value}),g}),w=e,v=i.inject("router");function k(g){if(t.isDebug&&console.log("unione btn click",n.widget,g),!(s.value.click&&s.value.click(p.value,n.widget,g)==!1)){if(n.widget.action?.type=="drawer"||n.widget.action?.type=="dialog")m.value.open=!0;else if(n.widget.action?.type=="route"&&(n.widget.action?.href||n.widget.action?.link)){if(n.widget.action.link&&n.editor?.type.value=="code")return;v.push({path:n.widget.action.href||n.widget.action?.link,query:y.value})}w("click",{btn:n.widget,event:g})}}function O(g){w("click",g)}return(g,u)=>{const N=i.resolveComponent("a-button"),V=i.resolveComponent("unione-btn"),C=i.resolveComponent("a-dropdown"),x=i.resolveComponent("a-drawer"),S=i.resolveComponent("a-modal");return d.value?(i.openBlock(),i.createBlock(ht,{key:0,class:i.normalizeClass(["unione-btn",a.widget.props?.block&&"unione-btn-block"]),model:a.editor?.model.value,onSetting:c,custome:!0,"setting-title":"按钮设置"},{default:i.withCtx(()=>[!a.widget.widget||a.widget.widget=="button"?(i.openBlock(),i.createBlock(N,i.mergeProps({key:0,disabled:h.value,size:a.widget.size||"small",type:a.type||a.widget.type,shape:a.widget.shape,class:"unione-btn-"+a.widget.name,loading:a.widget.loading,target:a.widget.action?.target,title:a.widget.tooltip,onClick:k},a.widget.props),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value)+" ",1)]),_:2},[a.widget.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(a.widget.icon)))]),key:"0"}:void 0]),1040,["disabled","size","type","shape","class","loading","target","title"])):i.createCommentVNode("",!0),a.widget.widget=="dropdown"?(i.openBlock(),i.createBlock(C,{key:1,trigger:[a.widget.trigger||"hover"],class:i.normalizeClass([a.widget.size||"small"])},{overlay:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["dropdown-overlay",a.widget.layout])},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(a.widget.items,M=>(i.openBlock(),i.createBlock(V,{key:M.name,class:"item",widget:M,editor:a.editor,preset:a.preset,ctx:a.ctx,onClick:O},null,8,["widget","editor","preset","ctx"]))),128))],2)]),default:i.withCtx(()=>[i.createVNode(N,{size:a.widget.size||"small"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value),1)]),_:1},8,["size"])]),_:1},8,["trigger","class"])):i.createCommentVNode("",!0),a.widget.action?.type=="drawer"?(i.openBlock(),i.createBlock(x,{key:2,open:m.value.open,"onUpdate:open":u[0]||(u[0]=M=>m.value.open=M),title:a.widget.action?.title,placement:a.widget.action?.position,maskClosable:a.widget.action?.maskClosable,width:a.widget.action?.width,bodyStyle:{padding:0,overflow:!a.widget.action.component||a.widget.action.component=="iframe"?"hidden":"auto"}},{default:i.withCtx(()=>[!a.widget.action.component||a.widget.action.component=="iframe"?(i.openBlock(),i.createElementBlock("iframe",{key:0,class:"unione-iframe unione-btn-iframe",src:b.value},null,8,ka)):i.createCommentVNode("",!0)]),_:1},8,["open","title","placement","maskClosable","width","bodyStyle"])):i.createCommentVNode("",!0),a.widget.action?.type=="dialog"?(i.openBlock(),i.createBlock(S,{key:3,open:m.value.open,"onUpdate:open":u[1]||(u[1]=M=>m.value.open=M),title:a.widget.action?.title,width:a.widget.action?.width,maskClosable:a.widget.action?.maskClosable,centered:"",footer:null},{default:i.withCtx(()=>[!a.widget.action.component||a.widget.action.component=="iframe"?(i.openBlock(),i.createElementBlock("iframe",{key:0,class:"unione-iframe unione-btn-iframe",src:b.value,style:i.normalizeStyle({height:a.widget.action?.height?a.widget.action?.height+"px":""})},null,12,ba)):i.createCommentVNode("",!0)]),_:1},8,["open","title","width","maskClosable"])):i.createCommentVNode("",!0),i.createVNode(ci,{ref_key:"btnSetting",ref:f,preset:n.preset},null,8,["preset"])]),_:1},8,["class","model"])):i.createCommentVNode("",!0)}}}),[["__scopeId","data-v-b868da76"]]),wa={key:0,class:"unione-widget-empty-tip"},xa=ne(i.defineComponent({__name:"tabs",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1}},setup(a){const e=a,t=i.ref(),n=i.computed(()=>e.editor?.widget(e.wid)||e.widget);return(l,s)=>{const o=i.resolveComponent("a-tab-pane"),r=i.resolveComponent("a-tabs");return i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-layout-tabs"]),model:e.editor?.model},{default:i.withCtx(()=>[n.value?(i.openBlock(),i.createBlock(r,{key:0,activeKey:t.value,"onUpdate:activeKey":s[0]||(s[0]=d=>t.value=d)},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.value.chidlren,(d,h)=>(i.openBlock(),i.createBlock(o,{key:h,class:"unione-layout-tab-pane"},{tab:i.withCtx(()=>[i.createElementVNode("span",null,[d.icon?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(d.icon),{key:0})):i.createCommentVNode("",!0),i.createTextVNode(" "+i.toDisplayString(d.title),1)])]),default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(d.chidlren,(f,c)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(f.widget),{key:c,wid:f.wid,editor:e.editor,widget:f},null,8,["wid","editor","widget"]))),128)),!d.chidlren||!d.chidlren.length?(i.openBlock(),i.createElementBlock("div",wa,i.toDisplayString(d.emptyTips),1)):i.createCommentVNode("",!0)]),_:2},1024))),128))]),_:1},8,["activeKey"])):i.createCommentVNode("",!0)]),_:1},8,["model"])}}}),[["__scopeId","data-v-7b565c89"]]),va={class:"title"},Ca={class:"text"},Sa={key:0,class:"reactive"},Na={key:1,class:"opts"},Ba={class:"warp"},Oa=ne(i.defineComponent({__name:"section",props:i.mergeModels({title:{type:String,required:!1},icon:{type:String,required:!1},type:{type:String,required:!1},location:{type:String,default:"left"},reactive:{type:Boolean,default:!1},wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1}},{modelValue:{type:Boolean,default:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(a){const e=a,t=i.computed(()=>e.editor?.widget(e.wid)||e.widget),n=i.computed(()=>t.value?.title||e.title),l=i.computed(()=>t.value?.icon||e.icon),s=i.computed(()=>t.value?.type||e.type),o=i.useModel(a,"modelValue");function r(){e.reactive&&(o.value=!o.value)}return(d,h)=>(i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-layout-section",o.value?"open":"close"]),model:e.editor?.model},{default:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["head",a.location,a.reactive&&"reactive"]),onClick:r},[i.createElementVNode("div",va,[s.value?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["type",s.value])},null,2)):i.createCommentVNode("",!0),l.value?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(l.value),{key:1,class:"icon"})):i.createCommentVNode("",!0),i.createElementVNode("span",Ca,i.toDisplayString(n.value),1)]),a.reactive?(i.openBlock(),i.createElementBlock("div",Sa,[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(o.value?"UpOutlined":"DownOutlined")))])):i.createCommentVNode("",!0),a.location=="left"?(i.openBlock(),i.createElementBlock("div",Na,[i.renderSlot(d.$slots,"opts",{},void 0,!0)])):i.createCommentVNode("",!0)],2),i.withDirectives(i.createElementVNode("div",Ba,[i.renderSlot(d.$slots,"default",{},void 0,!0)],512),[[i.vShow,o.value]])]),_:3},8,["class","model"]))}}),[["__scopeId","data-v-e75e9a84"]]),Va={class:"unione-props-setting unione-form-setting"},_a={class:"unione-form-btns"},Ma={key:0},Ta=["onClick"],Aa={class:"field-txt"},Ea=["onClick"],Ia={key:1,class:"field-txt"},Da=["onClick"],Pa={key:0,class:"field-txt"},Fa={key:3,class:"edit-field"},$a={key:0},Ra=["onClick"],La=ne(i.defineComponent({__name:"formSetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(a){const e=a,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:C})=>C+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"isForm",key:"isForm",width:"40px",align:"center"},{title:"详情",dataIndex:"isView",key:"isView",width:"40px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),n=i.computed(()=>{const C=e.editor.widget(e.wid)||{};return C.configs||(C.configs={}),C.configs.settings||(C.configs.settings={}),C.configs.settings.btns||(C.configs.settings.btns=[]),C}),l=i.computed(()=>(e.editor.dataModels()||[]).map(x=>({value:x.sn,label:x.title+"("+x.name+")"}))),s=i.computed(()=>{const C=n.value.configs.settings.btns,x=C.map(S=>S.name);if(!x.includes("save")){const S={title:"保存",type:"primary",index:0,visible:!0,name:"save"};C.splice(S.index,0,S)}if(!x.includes("submit")){const S={title:"提交",type:"primary",index:1,visible:!0,name:"submit"};let M=S.index||1;C.splice(M,0,S)}if(!x.includes("reset")){const S={title:"重置",type:"default",index:2,visible:!0,props:{danger:!0},name:"reset"};C.splice(S.index,0,S)}if(!x.includes("back")){const S={title:"返回",type:"default",index:3,visible:!0,name:"back"};C.splice(S.index,0,S)}return C}),o=i.ref(null);function r(C){o.value&&o.value.open(C,x=>{x.visible=!0,Object.keys(x).forEach(S=>{C[S]=x[S]}),n.value.configs.settings.btns.sort((S,M)=>{const T=S.index||1,E=M.index||1;return T-E}),n.value.configs.settings.btns=[...n.value.configs.btns]})}function d(){const C=n.value.configs.settings.btns.length+1;let x={title:"新增",name:"new_"+C,index:C,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{}};x.name="new_"+n.value.configs.settings.btns.length;const S=n.value.configs.settings.btns.filter(M=>M.name==x.name).length;S>0&&(x.name=x.name+S),n.value.configs.settings.btns.push(x),e.editor.widget(e.wid,n.value),o.value.open(x,M=>{Object.keys(M).forEach(T=>{x[T]=M[T]}),n.value.configs.btns=[...n.value.configs.btns]})}function h(C){const x=()=>{if(["save","submit","reset","back"].includes(C.name))C.visible=!1,n.value.configs.settings.btns=[...n.value.configs.settings.btns];else{const S=[];n.value.configs.settings.btns.forEach(M=>{M.name!=C.name&&S.push(M)}),n.value.configs.settings.btns=S}};J.Modal.confirm({title:"确认信息",content:"请确定删除该工具?",onOk:()=>{x()}})}const f=i.ref({visible:!1,field:{},props:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-textarea",label:"文本域"},{value:"a-input",label:"文本框"},{value:"a-checkbox",label:"多选框"},{value:"a-radio",label:"单选框"},{value:"a-input-number",label:"数值框"},{value:"a-select",label:"下拉框"},{value:"a-tree-select",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-switch",label:"开关"},{value:"a-slider",label:"滑块"}],widgetName:C=>{const x=f.value.widgets.filter(S=>S.value==C);return x[0]?x[0].label:C},toSetting:()=>{}}),c=i.ref({visible:!1,field:{},props:{},showInfo:C=>{let x="";return C.rules&&(x=C.rules.filter(S=>S.enable).length||""),x&&(x="("+x+")"),x},toSetting:()=>{const C=c.value.props,x={name:"range",trigger:C.trigger,whitespace:C.whitespace,message:C.rangeMessage};C.rangeMin!=null&&C.rangeMin!=null&&(x.min=C.rangeMin,x.enable=!0),C.rangeMax!=null&&C.rangeMax!=null&&(x.max=C.rangeMax,x.enable=!0);const S={name:"reg",trigger:C.trigger,whitespace:C.whitespace,message:C.regMessage};C.regExpress&&(S.pattern=C.regExpress,S.enable=!0),c.value.field.rules=[x,S],c.value.visible=!1,c.value.props={},console.log("rule",c.value.field.rules)}});function p(C){c.value.visible=!0,c.value.field=C;const x=C.rules||[],S={trigger:"change",whitespace:!0};x.forEach(M=>{M.name=="reg"&&(S.trigger=M.trigger,S.whitespace=M.whitespace,S.regExpress=M.pattern,S.regMessage=M.message),M.name=="range"&&(S.rangeMin=M.min,S.rangeMax=M.max,S.rangeMessage=M.message)}),c.value.props=S}const m=i.ref({title:"列头设置",prop:"isList",visible:!1,field:{},show:{},toSetting:()=>{m.value.visible=!1}});function b(C,x){const S=k.value.filter(T=>T.name==C.name);S.forEach(T=>{x!="isSort"?T[x]=!0:T[x]=!T[x]});const M=S[0];if(!(!M||x=="isSort")){switch(m.value.prop=x,m.value.field=C,M.show||(M.show={}),x){case"isQuery":M.show.query||(M.show.query={}),m.value.show=M.show.query,m.value.title=`查询设置/${C.title}(${C.name})`;break;case"isForm":M.show.form||(M.show.form={}),m.value.show=M.show.form,m.value.title=`表单设置/${C.title}(${C.name})`;break;case"isView":M.show.view||(M.show.view={}),m.value.show=M.show.view,m.value.title=`详情设置/${C.title}(${C.name})`;break;case"isList":M.show.list||(M.show.list={}),m.value.show=M.show.list,m.value.title=`列头设置/${C.title}(${C.name})`;break}m.value.visible=!0}}const y=i.ref({visible:!1,field:{},convert:{},optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],toAddOption:()=>{y.value.convert.options||(y.value.convert.options=[]),y.value.convert.options.push({label:"",value:""})},toDelOption:(C,x)=>{y.value.convert.options.splice(C,1)},toSetting:()=>{y.value.visible=!1}});function w(C){y.value.visible=!0,y.value.field=C,y.value.convert=C.convert||{}}const v=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),k=i.computed(()=>v.value.fields?.length?v.value.fields:[]),O={mounted:C=>C.focus()},g=i.ref({});function u(C,x){const S={};x=="convertName"?S[x]=C.convert?.type:S[x]=C[x]||"",g.value={},g.value[C.name]=S}function N(C,x){{g.value={};return}}function V(C,x){k.value.filter(M=>M.name==C.name).forEach(M=>{M[x]=!M[x]})}return(C,x)=>{const S=i.resolveComponent("a-divider"),M=i.resolveComponent("CloseOutlined"),T=i.resolveComponent("a-button"),E=i.resolveComponent("PlusOutlined"),I=i.resolveComponent("a-select"),L=i.resolveComponent("ToolOutlined"),A=i.resolveComponent("a-checkbox"),U=i.resolveComponent("a-table"),P=i.resolveComponent("a-select-option"),G=i.resolveComponent("a-form-item"),j=i.resolveComponent("a-form"),B=i.resolveComponent("a-modal"),F=i.resolveComponent("a-checkbox-group"),_=i.resolveComponent("a-input-number"),D=i.resolveComponent("a-input"),$=i.resolveComponent("a-col"),Q=i.resolveComponent("a-row");return i.openBlock(),i.createElementBlock("div",Va,[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[23]||(x[23]=[i.createTextVNode("按钮设置")])),_:1}),i.createElementVNode("div",_a,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,R=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:R.name,class:["btn",R.name,!R.visible&&"deleted"],type:R.visible?R.type:"default",size:R.size,ref_for:!0},R.props||{},{onClick:X=>r(R)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(R.title)+" ",1),R.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"btn-del",onClick:i.withModifiers(X=>h(R),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[R.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(R.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","btn-add"]),size:"small",onClick:x[0]||(x[0]=R=>d())},{default:i.withCtx(()=>[i.createVNode(E)]),_:1})]),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[24]||(x[24]=[i.createTextVNode("表单设置")])),_:1}),x[36]||(x[36]=i.createTextVNode(" 数据模型:")),i.createVNode(I,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":x[1]||(x[1]=R=>n.value.dataModel=R)},null,8,["options","value"]),i.createVNode(U,{columns:t.value,"data-source":k.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:R})=>[["widget","rules","convertName"].includes(R.key)?(i.openBlock(),i.createElementBlock("span",Ma,[i.createVNode(L),i.createTextVNode(" "+i.toDisplayString(R.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:R,text:X,record:Z})=>[["rules"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!c.value.showInfo(Z)&&"empty"]),onClick:ge=>p(Z)},[i.createElementVNode("span",Aa,i.toDisplayString(c.value.showInfo(Z)),1),c.value.showInfo(Z)?(i.openBlock(),i.createBlock(T,{key:0,type:"link"},{default:i.withCtx(()=>x[25]||(x[25]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Ta)):["widget"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!g.value[Z.name]||!Object.keys(g.value[Z.name]).includes(R.dataIndex))&&!X&&"empty"]),onClick:ge=>u(Z,R.dataIndex)},[g.value[Z.name]&&Object.keys(g.value[Z.name]).includes(R.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(I,{key:0,value:Z[R.dataIndex],"onUpdate:value":ge=>Z[R.dataIndex]=ge,options:f.value.widgets,onBlur:x[2]||(x[2]=ge=>N())},null,8,["value","onUpdate:value","options"])),[[O]]):(i.openBlock(),i.createElementBlock("span",Ia,i.toDisplayString(f.value.widgetName(X)),1))],10,Ea)):["convertName"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!g.value[Z.name]||!Object.keys(g.value[Z.name]).includes(R.dataIndex))&&!Z.convert?.type&&"empty"]),onClick:ge=>u(Z,R.dataIndex)},[g.value[Z.name]&&Object.keys(g.value[Z.name]).includes(R.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(I,{key:0,value:Z[R.dataIndex],"onUpdate:value":ge=>Z[R.dataIndex]=ge,options:[{value:"dict",label:"字典"},{value:"option",label:"静态"}],onBlur:x[3]||(x[3]=ge=>N())},null,8,["value","onUpdate:value"])),[[O]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[Z.convert?.type?(i.openBlock(),i.createElementBlock("span",Pa,i.toDisplayString(Z.convert.type=="dict"?"字典":"静态"),1)):i.createCommentVNode("",!0),Z.convert?.type?(i.openBlock(),i.createBlock(T,{key:1,type:"link",onClick:i.withModifiers(ge=>w(Z),["stop"])},{default:i.withCtx(()=>x[26]||(x[26]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,Da)):["isForm","isView"].includes(R.dataIndex)?(i.openBlock(),i.createElementBlock("div",Fa,[i.createVNode(A,{checked:Z[R.dataIndex],onClick:ge=>V(Z,R.dataIndex)},null,8,["checked","onClick"]),i.createVNode(T,{type:"link",onClick:ge=>b(Z,R.dataIndex)},{default:i.withCtx(()=>x[27]||(x[27]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(B,{visible:f.value.visible,"onUpdate:visible":x[5]||(x[5]=R=>f.value.visible=R),title:"控件设置",onOk:f.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:f.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[f.value.field.widget=="a-select"?(i.openBlock(),i.createBlock(G,{key:0,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(I,{value:f.value.props.mode,"onUpdate:value":x[4]||(x[4]=R=>f.value.props.mode=R),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(P,{value:"multiple"},{default:i.withCtx(()=>x[28]||(x[28]=[i.createTextVNode("多选")])),_:1}),i.createVNode(P,{value:"tags"},{default:i.withCtx(()=>x[29]||(x[29]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(B,{visible:c.value.visible,"onUpdate:visible":x[13]||(x[13]=R=>c.value.visible=R),title:"规则设置",onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:c.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[30]||(x[30]=[i.createTextVNode("基本设置")])),_:1}),i.createVNode(G,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(F,{value:c.value.props.trigger,"onUpdate:value":x[6]||(x[6]=R=>c.value.props.trigger=R),options:["change","blur"]},null,8,["value"])]),_:1}),c.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(G,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(A,{value:c.value.props.whitespace,"onUpdate:value":x[7]||(x[7]=R=>c.value.props.whitespace=R),checked:c.value.props.whitespace},{default:i.withCtx(()=>x[31]||(x[31]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["value","checked"])]),_:1})),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[32]||(x[32]=[i.createTextVNode("数值区间")])),_:1}),i.createVNode(G,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(_,{value:c.value.props.rangeMin,"onUpdate:value":x[8]||(x[8]=R=>c.value.props.rangeMin=R)},null,8,["value"]),x[33]||(x[33]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(_,{value:c.value.props.rangeMax,"onUpdate:value":x[9]||(x[9]=R=>c.value.props.rangeMax=R)},null,8,["value"])]),_:1}),i.createVNode(G,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.rangeMessage,"onUpdate:value":x[10]||(x[10]=R=>c.value.props.rangeMessage=R)},null,8,["value"])]),_:1}),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[34]||(x[34]=[i.createTextVNode("正则验证")])),_:1}),i.createVNode(G,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.regExpress,"onUpdate:value":x[11]||(x[11]=R=>c.value.props.regExpress=R)},null,8,["value"])]),_:1}),i.createVNode(G,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(D,{value:c.value.props.regMessage,"onUpdate:value":x[12]||(x[12]=R=>c.value.props.regMessage=R)},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(B,{visible:m.value.visible,"onUpdate:visible":x[20]||(x[20]=R=>m.value.visible=R),title:m.value.title,onOk:m.value.toSetting},{default:i.withCtx(()=>[i.createVNode(j,{model:m.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(G,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(_,{value:m.value.show.index,"onUpdate:value":x[14]||(x[14]=R=>m.value.show.index=R)},null,8,["value"])]),_:1}),["isQuery"].includes(m.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(G,{key:0,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.width,"onUpdate:value":x[15]||(x[15]=R=>m.value.show.width=R)},null,8,["value"])]),_:1})),["isForm","isView"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:1,label:"标题宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.labelWidth,"onUpdate:value":x[16]||(x[16]=R=>m.value.show.labelWidth=R)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isForm","isView"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:2,label:"控件宽度"},{default:i.withCtx(()=>[i.createVNode(D,{value:m.value.show.valueWidth,"onUpdate:value":x[17]||(x[17]=R=>m.value.show.valueWidth=R)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:3,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(I,{value:m.value.show.fixed,"onUpdate:value":x[18]||(x[18]=R=>m.value.show.fixed=R),options:[{value:"",label:"无"},{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(m.value.prop)?(i.openBlock(),i.createBlock(G,{key:4,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(I,{value:m.value.show.align,"onUpdate:value":x[19]||(x[19]=R=>m.value.show.align=R),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(B,{visible:y.value.visible,"onUpdate:visible":x[22]||(x[22]=R=>y.value.visible=R),title:y.value.convert.type=="dict"?"字典设置":"选项设置",onOk:y.value.toSetting},{default:i.withCtx(()=>[y.value.convert.type!="dict"?(i.openBlock(),i.createElementBlock("div",$a,[i.createVNode(T,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:y.value.toAddOption},{default:i.withCtx(()=>x[35]||(x[35]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(U,{columns:y.value.optionColumn,"data-source":y.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:R,record:X,index:Z})=>[R.dataIndex==="label"?(i.openBlock(),i.createBlock(D,{key:0,value:X.label,"onUpdate:value":ge=>X.label=ge,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),R.dataIndex==="value"?(i.openBlock(),i.createBlock(D,{key:1,value:X.value,"onUpdate:value":ge=>X.value=ge,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),R.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:ge=>y.value.toDelOption(Z,X)},"删除",8,Ra)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])])):i.createCommentVNode("",!0),y.value.convert.type=="dict"?(i.openBlock(),i.createBlock(j,{key:1,model:y.value.convert,name:"basic","label-col":{span:8},"wrapper-col":{span:16},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(Q,{type:"flex",style:{width:"100%"}},{default:i.withCtx(()=>[i.createVNode($,{span:24,order:1},{default:i.withCtx(()=>[i.createVNode(G,{label:"字典名称:"},{default:i.withCtx(()=>[i.createVNode(D,{value:y.value.convert.dict,"onUpdate:value":x[21]||(x[21]=R=>y.value.convert.dict=R)},null,8,["value"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):i.createCommentVNode("",!0)]),_:1},8,["visible","title","onOk"]),i.createVNode(ci,{ref_key:"btnSetting",ref:o},null,512)])}}}),[["__scopeId","data-v-c0f75bb9"]]),ja=ne(i.defineComponent({__name:"form",props:{editor:{type:Object,required:!1},widget:{type:Object,required:!1},form:{type:Object,required:!1}},setup(a,{expose:e}){const t=a,n=i.ref(!1),l=i.ref(),s=i.ref({}),o=i.ref(null);i.onMounted(()=>{if(d.value.dsn){const k=r.value.dataManager();d.value.primary&&k.psn(d.value.dsn),o.value.setDisabled=v,o.value.getValue=p,o.value.setValue=m,o.value.reset=b,l.value=k.useForm(d.value.dsn,o.value,O=>{s.value=O.body||{}})}t.editor||r.value.loadConfig({widgets:h.value}),t.form?.model&&r.value.setModel(t.form.model),y()});const r=i.computed(()=>t.editor||new ct),d=i.computed(()=>t.widget||t.form||{}),h=i.computed(()=>{let k=d.value.widgets||[];return!k.length&&t.form?.fields&&(k=t.form.fields),k.forEach(O=>{O.widget||(O.widget="unione-form-item"),O.control||(O.control="a-input")}),k}),f=i.inject("pageSetting"),c=i.computed(()=>d.value.setting||f?.form||{});i.provide("formSetting",c.value);function p(){return s.value}function m(k){s.value=k,y()}function b(){s.value={},y()}function y(){const k=O=>{O.widget=="unione-form-item"&&O.name&&(O.value!=null&&O.value!=null&&O.value!=""||O.value==0)&&(s.value[O.name]==null||s.value[O.name]==null||s.value[O.name]=="")&&(s.value[O.name]=O.value),O.widgets?.forEach(g=>{k(g)})};h.value.forEach(O=>{k(O)})}function w(){return o.value.validate()}function v(k=!0){n.value=k}return e({validate:w,getValue:p,setValue:m,reset:b,setDisabled:v}),(k,O)=>{const g=i.resolveComponent("a-form");return i.openBlock(),i.createBlock(ht,{class:"unione-form-widget","setting-title":"表单设置",model:r.value.model.value},i.createSlots({default:i.withCtx(()=>[i.createVNode(g,{ref_key:"formObj",ref:o,model:s.value,class:i.normalizeClass(["unione-form",r.value.model.value,"form-layout-col-"+(c.value.showColumn||3)])},{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.value,(u,N)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(u.widget),{key:N,widget:u,editor:r.value,value:s.value[u.name],"onUpdate:value":V=>s.value[u.name]=V,disabled:n.value,formValue:s.value},null,40,["widget","editor","value","onUpdate:value","disabled","formValue"]))),128))]),_:1},8,["model","class"])]),_:2},[a.editor&&d.value.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(La,{wid:d.value.wid,editor:a.editor},null,8,["wid","editor"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-9a034019"]]);function yl(a,e=!1){const t=Ie();if(!a)return Promise.reject("字典名称不能为空");const n=localStorage.getItem("UNIONE-DICT-"+a);return n&&e==!1?Promise.resolve(JSON.parse(n)):(t.isDebug&&console.log("进入:加载字典数据方法,dict name:"+a+",force:"+e),new Promise((l,s)=>{K.axios.admin({url:"/api/system/dict/load/"+a}).then(o=>{if(o.success){const r=o.body.filter(d=>d.dictName!=d.dictKey);r.forEach(d=>{d.value=d.dictKey,d.label=d.dictValue}),r.length?(localStorage.setItem("UNIONE-DICT-"+a,JSON.stringify(r)),l(r)):s("字典加载失败,dict:"+a+",字典项列表为空")}else t.isDebug&&console.error("字典加载失败,dict:"+a,o),s("字典加载失败,dict:"+a+",error:"+o.message)})}))}async function wl(a,e){const t=Ie();if(e==null||e==null||e=="undefined"||!(e+"").length)return Promise.reject("字典key为空");const n=await yl(a),l=n.filter(s=>s.dictKey==e);return l.length>0?Promise.resolve(l[0]):(t.isDebug&&console.log("字典项匹配失败,name:"+a+",key:"+e+"options:",n),Promise.reject("字典项匹配失败,name:"+a+",key:"+e))}async function za(a,e){const t=await wl(a,e);return Promise.resolve(t.dictValue)}const xl={load:yl,getLabel:za,getOption:wl};class Ke{convertObj;config;options;constructor(e){(!e||!e.types)&&console.error("转换器定义不能为空,type不能为空",e),e.valueField||(e.valueField="id"),e.labelField||(e.labelField="title"),this.convertObj=e,this.options=e.options||[],this.config=Ie()}load(e,t=!1){return!(e==null||e==null||e=="undefined"||!(e+"").length)&&this.options?.length&&this.options.filter(n=>n.value==e).length?Promise.resolve(this.options):this.convertObj.types=="dict"?new Promise((n,l)=>{if(!this.convertObj.dictName){l("字典名称不能为空,id:"+this.convertObj.id);return}xl.load(this.convertObj.dictName,t).then(s=>{this.options=s,typeof e=="number"&&this.options.forEach(o=>{o.value=parseInt(o.value)}),n(this.options)})}):this.convertObj.types=="option"?(this.options=this.convertObj.options||[],this.convertObj.options?.length?Promise.resolve(this.convertObj.options):(this.config.isDebug&&console.error("静态转换器选项为空,id:"+this.convertObj.id,this.convertObj),Promise.reject("静态转换器选项为空,id:"+this.convertObj.id))):!this.convertObj.id&&this.convertObj.types!="local"?Promise.reject("转换器id不能为空,type:"+this.convertObj.types):new Promise((n,l)=>{const s=this.convertObj.params||{body:{}};this.convertObj.pidField&&(s.pid=-1);const o=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:o,data:s,method:"POST"}).then(r=>{r.success?(this.options=r.body,this.$processOptions(this.options),typeof e=="number"&&this.options.forEach(d=>{d.value=parseInt(d.value)}),e==null||e==null||e=="undefined"||!(e+"").length?this.options.length?n(this.options):(this.config.isDebug&&console.error("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id,r),l("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id)):this.options.filter(h=>h.value==e).length?n(this.options):(s.body||(s.body={}),s.body[this.convertObj.valueField||"id"]=e,K.axios.admin({url:o,data:s,method:"POST"}).then(h=>{if(h.success){const f={};this.options.forEach(c=>{f[e]=!0}),h.body.forEach(c=>{f[c.value]||this.options.push(c)}),n(this.options)}else l("数据选项为空,type:"+this.convertObj.types+",id:"+this.convertObj.id)}))):(this.config.isDebug&&console.error("数据选项加载失败,type:"+this.convertObj.types+",id:"+this.convertObj.id,r),l("数据选项加载失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",error:"+r.message))})})}convert(e){if(e==null||e==null||e=="undefined"||!(e+"").length)return Promise.reject("value为空");if(this.convertObj.types=="dict")return this.convertObj.dictName?xl.getLabel(this.convertObj.dictName,e):Promise.reject("字典名称不能为空");if(this.convertObj.types=="option"){if(this.convertObj.options?.length){const t=this.convertObj.options.filter(n=>n.value==e);return t.length?Promise.resolve(t[0].label):(this.config.isDebug&&console.error("静态转换器选项匹配失败,id:"+this.convertObj.id+",value:"+e,this.convertObj),Promise.reject("静态转换器选项匹配失败,id:"+this.convertObj.id+",value:"+e))}return Promise.reject("静态转换器选项为空,id:"+this.convertObj.id)}if(this.options?.length){const t=this.options.filter(n=>n.value==e);if(t.length)return Promise.resolve(t[0].label)}return new Promise((t,n)=>{this.load(e).then(l=>{const s=l.filter(o=>o.value==e);if(s.length)return t(s[0].label);n()})})}children(e=-1){return this.config.isDebug&&console.log("进入:加载下级数据项方法,id:"+this.convertObj.id+",type:"+this.convertObj.types+",pid:"+e),this.convertObj.pidField?this.convertObj.types=="dict"||this.convertObj.types=="option"?Promise.reject("字典/静态转换器不支持该方法,type:"+this.convertObj.types+",id:"+this.convertObj.id):new Promise((n,l)=>{const s=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:s,data:e,method:"POST"}).then(o=>{o.success?(this.$processOptions(o.body),this.options=[...this.options,...o.body],n(o.body)):(this.config.isDebug&&console.error("加载下级数据项失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",pid:"+e,o),l("加载下级数据项失败,type:"+this.convertObj.types+",id:"+this.convertObj.id+",pid:"+e+",error:"+o.message))})}):Promise.reject("转换器未设置parentField,id:"+this.convertObj.id)}search(e){return this.config.isDebug&&console.log("进入:搜索数据选项方法,id:"+this.convertObj.id+",type:"+this.convertObj.types+",keywords:"+e),this.convertObj.types=="dict"||this.convertObj.types=="option"?Promise.resolve(this.options.filter(t=>t.label.indexOf(e)>=0)):new Promise(t=>{const n=this.convertObj.types=="local"?this.convertObj.url:"/api/data/convertor/"+this.convertObj.id;K.axios.admin({url:n,data:{body:{keywords:e}},method:"POST"}).then(l=>{l.success?(this.$processOptions(l.body),t(l.body)):t([])})})}$processOptions(e){return this.convertObj.types=="local"&&e.forEach(t=>{this.convertObj.idField&&(t.id=t[this.convertObj.idField]),this.convertObj.pidField&&(t.pid=t[this.convertObj.pidField]),t.value=t[this.convertObj.valueField||"id"],t.label=t[this.convertObj.labelField||"title"]}),e}}const qa=["innerHTML"],Ua={key:2,class:"text-view"},Wa=ne(i.defineComponent({__name:"formItem",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},formValue:{type:Object,required:!0},disabled:{type:Boolean,defualt:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(a){const e=a,t=i.useModel(a,"value"),n=i.computed(()=>s.value.showFormat?s.value.showFormat.call(this,t.value,{label:w.value,form:e.formValue}):w.value||t.value),l=i.inject("formSetting");i.onMounted(()=>{o.value.value!=null&&typeof o.value.value<"u"&&(e.formValue[o.value.name]==null||e.formValue[o.value.name]==null||typeof e.formValue[o.value.name]>"u")&&(t.value=o.value.value,o.value.widget=="unione-check-box"&&(Array.isArray(o.value.value)||(typeof o.value.value=="string"?t.value=o.value.value.split(","):t.value=[o.value.value])))});const s=i.ref({}),o=i.computed(()=>{const v=e.editor?.widget(e.wid)||e.widget||{};return v.event&&Object.keys(v.event).forEach(k=>{const O=v.event[k];O&&(s.value[k]=null,typeof O=="function"?s.value[k]=O:O.enable&&O.scriptText&&(s.value[k]=new Function("value","ctx",O.scriptText)))}),v}),r=i.computed(()=>!(s.value.visible&&s.value.visible(e.formValue[o.value.name],e.formValue)==!1)),d=i.computed(()=>s.value.title&&s.value.title(e.formValue[o.value.name],e.formValue)||o.value.title),h=i.computed(()=>s.value.change&&s.value.change(e.formValue[o.value.name],e.formValue)||o.value.change),f=i.ref({}),c=i.computed(()=>{const v=[],k=o.value.rule||{};let O=o.value.props?.required||o.value.required;if(s.value.required&&(O=s.value.required(e.formValue[o.value.name],e.formValue)),O&&v.push({required:!0,whitespace:k?.whitespace||!1,trigger:k?.trigger||l.ruleTrigger||"change",validator:(g,u)=>(k?.whitespace&&u&&typeof u=="string"&&(u=u.trim()),u!=null&&u!=null&&(u+"").replace(/\s+/g,"").length>0?Promise.resolve():Promise.reject(d.value+"不能为空!"))}),k.advance&&f.value[k.advance]){const g=f.value[k.advance];v.push({pattern:g.pattern,message:g.message||"表单验证不通过!",trigger:k.trigger||l.ruleTrigger||"change"})}return k.regExpress&&v.push({pattern:k.regExpress,message:k.regMessage||"表单验证不通过!",trigger:k.trigger||l.ruleTrigger||"change"}),o.value.dataLen&&v.push({validator:(g,u)=>u&&(u+"").length>o.value.dataLen?Promise.reject("最大长度["+o.value.dataLen+"],当前:["+(u+"").length+"]"):Promise.resolve(),trigger:k?.trigger||l.ruleTrigger||"change"}),v}),p=i.computed(()=>{const v=o.value.props||{};if(o.value.control=="a-input-number"){const k=o.value.rule||{};k.rangeMin!=null&&k.rangeMin!=null&&(v.min=k.rangeMin),k.rangeMax!=null&&k.rangeMax!=null&&(v.max=k.rangeMax)}return o.value.control=="a-date-picker"&&o.value.view?.dataFormat&&(v.format=o.value.view.dataFormat,v.valueFormat=o.value.view.dataFormat),o.value.required&&(v.required=o.value.required),v}),m=i.computed(()=>{const v=o.value.css||{},k=["form-item-"+o.value.name];return v.cssName&&k.push(v.cssName),l.platform=="app"?v.cssName?typeof v.cssName=="string"&&v.cssName.indexOf("all-line")<0&&k.push("all-line"):k.push("all-line"):o.value.view?.width&&(o.value.view.width>=3?(!v.cssName||typeof v.cssName=="string"&&v.cssName.indexOf("all-line")<0)&&k.push("all-line"):o.value.view.width==2&&k.push("2in-line")),k}),b=i.computed(()=>{const v=l.showColumn||3;let k=o.value.view?.labelWidth||l.labelWidth||9;return o.value.css?.cssName&&v>1&&typeof o.value.css.cssName=="string"&&o.value.css.cssName.indexOf("all-line")>=0?{span:Math.round(k/v)}:o.value.view?.width>=3&&v>1?{span:Math.round(k/v)}:{span:k}}),y=i.computed(()=>{const v=l.showColumn||3;let k=o.value.view?.valueWidth||l.valueWidth||19;return o.value.css?.cssName&&v>1&&m.value.includes("all-line")?{}:{span:k}}),w=i.ref();return i.watch(t,()=>{t.value&&e.editor?.model.value=="view"&&o.value.convert&&new Ke(o.value.convert).convert(t.value.toString()).then(v=>{w.value=v})}),(v,k)=>{const O=i.resolveComponent("a-form-item");return i.openBlock(),i.createBlock(ht,{class:i.normalizeClass(["unione-form-item",m.value]),style:i.normalizeStyle(o.value.css?.cssText)},{default:i.withCtx(()=>[r.value?(i.openBlock(),i.createBlock(O,{key:0,label:d.value,name:o.value.name,labelCol:b.value,wrapperCol:y.value,required:o.value.props?.required,rules:c.value,help:(!e.editor||e.editor.model.value!="view")&&o.value.props?.help,tooltip:o.value.props?.tooltip},{default:i.withCtx(()=>[!e.editor||e.editor.model.value!="view"&&o.value.view!="html"?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(o.value.control||"a-input"),i.mergeProps({key:0,wid:o.value.wid,widget:o.value,editor:e.editor,disabled:a.disabled,onChange:h.value,value:t.value,"onUpdate:value":k[0]||(k[0]=g=>t.value=g)},p.value,{style:o.value.css?.props}),null,16,["wid","widget","editor","disabled","onChange","value","style"])):o.value.view=="html"?(i.openBlock(),i.createElementBlock("div",{key:1,class:"text-view text-html",innerHTML:n.value},null,8,qa)):(i.openBlock(),i.createElementBlock("div",Ua,i.toDisplayString(n.value),1))]),_:1},8,["label","name","labelCol","wrapperCol","required","rules","help","tooltip"])):i.createCommentVNode("",!0)]),_:1},8,["class","style"])}}}),[["__scopeId","data-v-c633076a"]]);function tn(a,e=350){let t=null;return n=>{clearTimeout(t),t=setTimeout(()=>{a(n)},e)}}const Ha=ne(i.defineComponent({__name:"selectBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(a){Ie();const e=a,t=i.useModel(a,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]),s=i.computed(()=>(d.value.convert||e.convert||{}).search||!1),o=tn(f=>{h.value.search(f).then(c=>{n.value=c})},500);i.onMounted(()=>{h.value.load(t.value).then(f=>{n.value=f})});const r=i.ref({}),d=i.computed(()=>{const f=e.editor?.widget(e.wid)||e.widget||{};return f.event&&Object.keys(f.event).forEach(c=>{const p=f.event[c];r.value[c]=null,p.enable&&p.scriptText&&(r.value[c]=new Function("value","ctx",p.scriptText))}),f}),h=i.computed(()=>{const f=d.value.convert||e.convert||{};return new Ke(f)});return i.watch(t,()=>{t.value&&h.value.load(t.value).then(f=>{n.value=f})}),i.watch(()=>d.value.convert||e.convert||{},()=>{h.value.load().then(f=>{n.value=f})}),(f,c)=>{const p=i.resolveComponent("a-select");return i.openBlock(),i.createBlock(p,{class:"unione-form-select",options:l.value,showSearch:s.value,value:t.value,"onUpdate:value":c[0]||(c[0]=m=>t.value=m),onSearch:i.unref(o)},null,8,["options","showSearch","value","onSearch"])}}}),[["__scopeId","data-v-d885ca4f"]]),Ka=ne(i.defineComponent({__name:"switchBox",props:i.mergeModels({editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(a){const e=a,t=i.useModel(a,"value"),n=i.ref({});i.onMounted(()=>{o.value?.load(t.value).then(r=>{r.forEach(d=>{d.value&&(d.value=="1"||d.value=="true"||d.value=="TRUE")?(n.value.checkedChildren=d.label,d.value=="true"||d.value=="TRUE"?n.value.checkedValue=!0:n.value.checkedValue=1):(n.value.unCheckedChildren=d.label,d.value=="false"||d.value=="FALSE"?n.value.unCheckedValue=!1:n.value.unCheckedValue=0)})})});const l=i.ref({}),s=i.computed(()=>{const r=e.widget||{};return r.event&&Object.keys(r.event).forEach(d=>{const h=r.event[d];l.value[d]=null,h.enable&&h.scriptText&&(l.value[d]=new Function("value","ctx",h.scriptText))}),r}),o=i.computed(()=>{const r=s.value.convert||e.convert;return r?new Ke(r):null});return(r,d)=>{const h=i.resolveComponent("a-switch");return i.openBlock(),i.createBlock(h,i.mergeProps({class:"unione-form-switch"},n.value,{checked:t.value,"onUpdate:checked":d[0]||(d[0]=f=>t.value=f)}),null,16,["checked"])}}}),[["__scopeId","data-v-a56d945e"]]),Qa=ne(i.defineComponent({__name:"radioBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(a){const e=a,t=i.useModel(a,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]);i.onMounted(()=>{r.value.load(t.value||o.value.value).then(d=>{n.value=d})});const s=i.ref({}),o=i.computed(()=>{const d=e.editor?.widget(e.wid)||e.widget||{};return d.event&&Object.keys(d.event).forEach(h=>{const f=d.event[h];s.value[h]=null,f.enable&&f.scriptText&&(s.value[h]=new Function("value","ctx",f.scriptText))}),d}),r=i.computed(()=>{const d=o.value.convert||e.convert||{};return new Ke(d)});return(d,h)=>{const f=i.resolveComponent("a-radio-group");return i.openBlock(),i.createBlock(f,{class:"unione-form-radio",options:l.value,value:t.value,"onUpdate:value":h[0]||(h[0]=c=>t.value=c)},null,8,["options","value"])}}}),[["__scopeId","data-v-761054e0"]]),Ga=ne(i.defineComponent({__name:"checkBox",props:i.mergeModels({wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},convert:{type:Object,required:!1},options:{type:Array,required:!1}},{value:{},valueModifiers:{}}),emits:["update:value"],setup(a){const e=a,t=i.useModel(a,"value"),n=i.ref([]),l=i.computed(()=>n.value?.length?n.value:e.options?.length?e.options:[]);i.onMounted(()=>{r.value.load(t.value||o.value.value).then(d=>{n.value=d})});const s=i.ref({}),o=i.computed(()=>{const d=e.editor?.widget(e.wid)||e.widget||{};return d.event&&Object.keys(d.event).forEach(h=>{const f=d.event[h];s.value[h]=null,f.enable&&f.scriptText&&(s.value[h]=new Function("value","ctx",f.scriptText))}),d}),r=i.computed(()=>{const d=o.value.convert||e.convert||{};return new Ke(d)});return(d,h)=>{const f=i.resolveComponent("a-checkbox-group");return i.openBlock(),i.createBlock(f,{class:"unione-form-checkbox",options:l.value,value:t.value,"onUpdate:value":h[0]||(h[0]=c=>t.value=c)},null,8,["options","value"])}}}),[["__scopeId","data-v-e2f0f7fc"]]),Ya=ne(i.defineComponent({__name:"pwdBox",props:{value:{},valueModifiers:{}},emits:["update:value"],setup(a){const e=i.ref(),t=i.useModel(a,"value");return i.watch(()=>e.value,()=>{e.value?t.value=K.utils.sm2Encrypt(e.value):t.value=""}),(n,l)=>{const s=i.resolveComponent("a-input-password");return i.openBlock(),i.createBlock(s,{class:"unione-form-password",value:e.value,"onUpdate:value":l[0]||(l[0]=o=>e.value=o)},null,8,["value"])}}}),[["__scopeId","data-v-4515a2af"]]),Xa={class:"unione-props-setting unione-query-setting"},Ja={class:"unione-query-opts"},Za={key:0},er=["onClick"],tr={key:1},ir={key:1,class:"edit-field"},nr=["onClick"],lr=ne(i.defineComponent({__name:"querySetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(a){const e=a,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:O})=>O+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"查询",dataIndex:"isQuery",key:"isQuery",width:"30px",align:"center"},{title:"查询类型",dataIndex:"queryType",key:"queryType",width:"55px",align:"center"},{title:"显示顺序",dataIndex:"showIndex",key:"showIndex",width:"55px",align:"center"}]),n=i.computed(()=>{const O=e.editor.widget(e.wid)||{};return O.configs||(O.configs={}),O.configs.btns||(O.configs.btns=[]),O}),l=i.computed(()=>(e.editor.dataModels()||[]).map(g=>({value:g.sn,label:g.title+"("+g.name+")"}))),s=i.computed(()=>{const O=[],g=[];return n.value.configs.btns||(n.value.configs.btns=[]),n.value.configs.btns.forEach(u=>{O.push(u),g.push(u.name)}),g.includes("query")||O.splice(0,0,{visible:!0,name:"query",title:"搜索",type:"primary"}),g.includes("reset")||O.splice(1,0,{visible:!0,name:"reset",title:"重置",type:"default"}),g.includes("reset")||O.splice(1,0,{visible:!0,name:"advanced",title:"高级搜索",type:"default"}),O.sort((u,N)=>{const V=u.index||1,C=N.index||1;return V-C}),O}),o=i.ref(null);function r(O){o.value&&o.value.open(O,g=>{g.visible=!0,Object.keys(g).forEach(u=>{O[u]=g[u]}),n.value.configs.btns.sort((u,N)=>{const V=u.index||1,C=N.index||1;return V-C}),n.value.configs.btns=[...n.value.configs.btns]})}function d(){const O=n.value.configs.btns.length+1;let g={title:"新增",name:"new_"+O,size:"default",index:O,visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{clickScript:"",titleScript:"",disableScript:"",visibleScript:""}};n.value.configs.btns.push(g),e.editor.widget(e.wid,n.value),o.value.open(g,u=>{Object.keys(u).forEach(N=>{g[N]=u[N]}),n.value.configs.btns=[...n.value.configs.btns]})}function h(O){const g=()=>{if(["query","reset","advanced"].includes(O.name))O.visible=!1,n.value.configs.btns=[...n.value.configs.btns];else{const u=[];n.value.configs.btns.forEach(N=>{N.name!=O.name&&u.push(N)}),n.value.configs.btns=u}};J.Modal.confirm({title:"确认信息",content:"请确定删除该操作?",onOk:()=>{g()}})}const f=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),c=i.computed(()=>f.value.fields?.length?f.value.fields:[]),p={mounted:O=>O.focus()},m=i.ref({});function b(){const O=Object.keys(m.value);if(O.length)for(let g in O){const u=c.value.filter(N=>N.name==g);if(u&&u[0]){let N=m.value[g];Object.keys(N).forEach(V=>{if(V=="showIndex"){const C=u[0].show?.query||{};u[0].show||(u[0].show={}),u[0].show.query={...C,index:N[V]}}else u[0][V]=N[V]})}}m.value={}}function y(O,g){b();const u={};u[g]=O[g]||"",g=="showIndex"&&(u[g]=O.show?.query?.index),m.value[O.name]=u}function w(O,g){if(!O||!g){m.value={};return}const u=m.value[O.name][g];if(g=="showIndex"){const N=O.show?.query||{};O.show||(O.show={}),O.show.query={...N,index:u}}else O[g]=u;m.value={}}function v(O,g){c.value.filter(N=>N.name==O.name).forEach(N=>{N[g]=!N[g]})}const k=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:O=>{const g=k.value.options.filter(u=>u.value==O);return g[0]?g[0].label:O}});return(O,g)=>{const u=i.resolveComponent("a-divider"),N=i.resolveComponent("CloseOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("PlusOutlined"),x=i.resolveComponent("a-select"),S=i.resolveComponent("ToolOutlined"),M=i.resolveComponent("a-checkbox"),T=i.resolveComponent("a-input-number"),E=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",Xa,[i.createVNode(u,{orientation:"left"},{default:i.withCtx(()=>g[3]||(g[3]=[i.createTextVNode("查询按钮")])),_:1}),i.createElementVNode("div",Ja,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,I=>(i.openBlock(),i.createBlock(V,i.mergeProps({key:I.name,class:["btn",I.name,!I.visible&&"deleted"],type:I.visible?I.type:"default",size:I.size||"default",ref_for:!0},I.props||{},{onClick:L=>r(I)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(I.title)+" ",1),I.visible?(i.openBlock(),i.createBlock(N,{key:0,class:"btn-del",onClick:i.withModifiers(L=>h(I),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[I.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(I.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(V,{class:i.normalizeClass(["btn","btn-add"]),onClick:g[0]||(g[0]=I=>d()),size:"small"},{default:i.withCtx(()=>[i.createVNode(C)]),_:1})]),i.createVNode(u,{orientation:"left"},{default:i.withCtx(()=>g[4]||(g[4]=[i.createTextVNode("查询字段")])),_:1}),g[5]||(g[5]=i.createTextVNode(" 数据模型:")),i.createVNode(x,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":g[1]||(g[1]=I=>n.value.dataModel=I)},null,8,["options","value"]),i.createVNode(E,{columns:t.value,"data-source":c.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:I})=>[["showIndex","queryType"].includes(I.key)?(i.openBlock(),i.createElementBlock("span",Za,[i.createVNode(S),i.createTextVNode(" "+i.toDisplayString(I.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:I,text:L,record:A})=>[["queryType"].includes(I.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!m.value[A.name]||!Object.keys(m.value[A.name]).includes(I.dataIndex))&&!L&&"empty"]),onClick:U=>y(A,I.dataIndex)},[m.value[A.name]&&Object.keys(m.value[A.name]).includes(I.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(x,{key:0,value:A[I.dataIndex],"onUpdate:value":U=>A[I.dataIndex]=U,allowClear:!0,options:k.value.options,onBlur:g[2]||(g[2]=U=>w())},null,8,["value","onUpdate:value","options"])),[[p]]):(i.openBlock(),i.createElementBlock("span",tr,i.toDisplayString(k.value.showLabel(L)),1))],10,er)):["isQuery"].includes(I.dataIndex)?(i.openBlock(),i.createElementBlock("div",ir,[i.createVNode(M,{checked:A[I.dataIndex],onClick:U=>v(A,I.dataIndex)},null,8,["checked","onClick"])])):I.dataIndex=="showIndex"?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!m.value[A.name]||!Object.keys(m.value[A.name]).includes(I.dataIndex))&&!L&&"empty"]),onClick:U=>y(A,I.dataIndex)},[m.value[A.name]&&Object.keys(m.value[A.name]).includes(I.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(T,{key:0,value:m.value[A.name][I.dataIndex],"onUpdate:value":U=>m.value[A.name][I.dataIndex]=U,onBlur:U=>w(A,I.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[p]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(A.show?.query?.index||" "),1)],64))],10,nr)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(ci,{ref_key:"btnSetting",ref:o},null,512)])}}}),[["__scopeId","data-v-ce575063"]]),sr={class:"query-btn"},or={class:"btn-advanced-overlay"},vl=ne(i.defineComponent({__name:"queryForm",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},fields:{type:Array},params:{type:Object,default(){return{}}}},emits:["query","reset","btnClick"],setup(a,{emit:e}){const t=a,n=i.computed(()=>{const w=t.editor?.widget(t.wid)||t.widget||{};return w.btns||(w.btns=[]),w}),l=i.computed(()=>({visible:!0,name:"keywords",title:"关键字",placeholder:"请输入搜索内容",...n.value.keywords||{}})),s=i.computed(()=>{let w=[];return n.value.fields?.length&&(w=n.value.fields),w.length==0&&t.fields?.length&&(w=t.fields),w.sort((v,k)=>{const O=v.show?.query?.index||1,g=k.show?.query?.index||1;return O-g}),w.forEach(v=>{!v.widget&&!v.control&&v.convert&&(v.widget="unione-select-box"),v.widget=v.widget||v.control||"a-input",v.defaultValue!=null&&v.defaultValue!="undefined"&&typeof v.defaultValue<"u"&&(f.value[v.name]=v.defaultValue,v.value=v.defaultValue)}),w}),o=i.computed(()=>n.value.labelWidth||7),r=i.computed(()=>{const w=n.value.btns.filter(v=>v.name=="advanced")[0]||{};return w.event?.clickScript&&(w.event.click=new Function("ctx","btn","event",w.event.clickScript)),w.event?.disableScript&&(w.event.disable=new Function("ctx","btn",w.event.disableScript)),w.event?.visibleScript&&(w.event.visible=new Function("ctx","btn",w.event.visibleScript)),{visible:!0,name:"advanced",title:"高级搜索",...w}}),d=["query","reset","advanced"],h=i.computed(()=>{const w=n.value.btns.filter(k=>k.name!="advanced"),v=[];return w.forEach(k=>{k.size||(k.size="default"),v.push(k.name)}),v.includes("query")||w.splice(0,0,{visible:!0,name:"query",title:"查询",size:"default",type:"primary"}),v.includes("reset")||w.splice(1,0,{visible:!0,name:"reset",title:"重置",size:"default",type:"default"}),w.sort((k,O)=>{const g=k.index||1,u=O.index||1;return g-u}),w}),f=i.ref({}),c=i.computed(()=>{const w={};return n.value.params?Object.keys(n.value.params).forEach(v=>{w[v]=n.value.params[v]}):t.params&&Object.keys(t.params).forEach(v=>{w[v]=t.params[v]}),w});i.onMounted(()=>{t.editor?.ebus.$on("query-form-params",w=>{n.value.params=w}),b()});const p=e;function m({btn:w,event:v}){console.log("unione query form btn click",w,v),w.name=="query"&&b(),w.name=="reset"&&y(),p("btnClick",{btn:w,event:v})}function b(){const w=[];s.value.forEach(k=>{k.visible&&w.push(k.name)});const v={params:{...c.value},keywords:""};Object.keys(f.value).forEach(k=>{w.includes(k)&&(v.params[k]=f.value[k])}),l.value.visible&&f.value[l.value.name]&&(v.keywords=f.value[l.value.name]),p("query",v),t.editor?.ebus.$emit("table-list-search",v)}function y(){f.value={},s.value.forEach(v=>{v.visible=!1});const w={params:{...c.value},keywords:""};p("reset",w),t.editor?.ebus.$emit("table-list-reset",w)}return(w,v)=>{const k=i.resolveComponent("a-input"),O=i.resolveComponent("a-form-item"),g=i.resolveComponent("unione-btn"),u=i.resolveComponent("a-checkbox"),N=i.resolveComponent("DownOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("a-dropdown"),x=i.resolveComponent("a-form");return i.openBlock(),i.createBlock(ht,{class:"unione-query-form",model:t.editor?.model.value,"setting-title":"查询设置"},i.createSlots({default:i.withCtx(()=>[i.createVNode(x,{model:f.value,layout:"horizontal","label-col":{span:o.value}},{default:i.withCtx(()=>[l.value.visible?(i.openBlock(),i.createBlock(O,{key:0,label:l.value.title,class:"query-field keywords",name:l.value.name,style:i.normalizeStyle({width:o.value})},{default:i.withCtx(()=>[i.createVNode(k,{placeholder:l.value.placeholder,value:f.value[l.value.name],"onUpdate:value":v[0]||(v[0]=S=>f.value[l.value.name]=S),allowClear:"",onKeyup:i.withKeys(b,["enter"])},null,8,["placeholder","value"])]),_:1},8,["label","name","style"])):i.createCommentVNode("",!0),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,S=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:S.name},[S.visible?(i.openBlock(),i.createBlock(O,{key:0,label:S.title,class:i.normalizeClass(["query-field",S.name]),style:i.normalizeStyle({width:o.value}),name:S.name},{default:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(S.widget),i.mergeProps({placeholder:S.placeholder,value:f.value[S.name],"onUpdate:value":M=>f.value[S.name]=M,ref_for:!0},S.props||{},{allowClear:"",widget:S}),null,16,["placeholder","value","onUpdate:value","widget"]))]),_:2},1032,["label","class","style","name"])):i.createCommentVNode("",!0)],64))),128)),i.createElementVNode("div",sr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.value,S=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:S.name},[S.visible!=!1?(i.openBlock(),i.createBlock(g,{key:0,widget:S,editor:a.editor,onClick:m,preset:d},null,8,["widget","editor"])):i.createCommentVNode("",!0)],64))),128)),r.value.visible&&s.value.length?(i.openBlock(),i.createBlock(C,{key:0,class:"btn btn-advanced",trigger:[r.value.trigger||"hover"]},{overlay:i.withCtx(()=>[i.createElementVNode("div",or,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,S=>(i.openBlock(),i.createBlock(u,{key:S.name,class:"item",checked:S.visible,onClick:M=>S.visible=!S.visible},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(S.title),1)]),_:2},1032,["checked","onClick"]))),128))])]),default:i.withCtx(()=>[i.createVNode(V,null,{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(r.value.title)+" ",1),i.createVNode(N)]),_:1})]),_:1},8,["trigger"])):i.createCommentVNode("",!0)])]),_:1},8,["model","label-col"])]),_:2},[t.editor&&t.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(lr,{editor:t.editor,wid:t.wid},null,8,["editor","wid"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-05f95e36"]]),ar={class:"unione-props-setting unione-table-setting"},rr={class:"unione-table-tools"},dr={key:1,class:"unione-table-opts"},cr={key:0},hr=["onClick"],fr={key:1,class:"edit-field"},ur=["onClick"],pr={key:1},mr=ne(i.defineComponent({__name:"tableSetting",props:{wid:{type:String,required:!0},editor:{type:Object,required:!0}},setup(a){const e=a,t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:C})=>C+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"显示",dataIndex:"isList",key:"isList",width:"30px",align:"center"},{title:"排序",dataIndex:"isSort",key:"isSort",width:"30px",align:"center"},{title:"显示顺序",dataIndex:"showIndex",key:"showIndex",width:"55px",align:"center"},{title:"对齐方式",dataIndex:"align",key:"align",width:"55px",align:"center",options:[{value:"left",label:"居左"},{value:"center",label:"居中"},{value:"right",label:"居右"}],showLabel(C,x){let S=C.filter(M=>M.value==x);return S&&S[0]&&S[0].label||x}},{title:"固定位置",dataIndex:"fixed",key:"fixed",width:"55px",align:"center",options:[{value:"left",label:"靠左"},{value:"right",label:"靠右"}],showLabel(C,x){let S=C.filter(M=>M.value==x);return S&&S[0]&&S[0].label||x}},{title:"列宽",dataIndex:"showWidth",key:"showWidth",width:"50px",align:"center"}]),n=i.computed(()=>{const C=e.editor.widget(e.wid)||{};return C.configs||(C.configs={}),C.configs.leftBtns||(C.configs.leftBtns=[]),C.configs.rightBtns||(C.configs.rightBtns=[]),C.configs.operation||(C.configs.operation={}),C.configs.operation.btns||(C.configs.operation.btns=[]),C.configs.operation.more||(C.configs.operation.more={}),C}),l=i.computed(()=>(e.editor.dataModels()||[]).map(x=>({value:x.sn,label:x.title+"("+x.name+")"}))),s=i.computed(()=>{if(!n.value)return[];const C=[],x=n.value.configs.leftBtns;if(x.forEach(S=>{C.push(S.name)}),!C.includes("add")){const S={visible:!0,title:"新增",icon:"PlusOutlined",size:"small",index:0,type:"primary",props:{danger:!1,block:!1,ghost:!1},name:"add"};x.splice(0,0,S)}if(!C.includes("delBatch")){const S={visible:!0,title:"批量删除",icon:"DeleteOutlined",size:"small",index:1,type:"primary",props:{danger:!0,block:!1,ghost:!1},name:"delBatch"};x.splice(1,0,S)}return x}),o=i.computed(()=>{if(!n.value)return[];const C=[],x=n.value.configs.rightBtns;if(x.forEach(S=>{C.push(S.name)}),!C.includes("downData")){const S={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"导出",index:0,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downData"};x.splice(0,0,S)}if(!C.includes("impData")){const S={visible:!0,title:"导入",icon:"CloudUploadOutlined",size:"small",index:1,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"impData"};x.splice(1,0,S)}if(!C.includes("expData")){const S={visible:!0,title:"导出",icon:"CloudUploadOutlined",size:"small",index:2,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"expData"};x.splice(2,0,S)}if(!C.includes("downTmpl")){const S={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"模版",index:3,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downTmpl"};x.splice(3,0,S)}return x});function r(C,x){C=="left"?f.value.open(x,S=>{S.visible=!0,Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.leftBtns.sort((M,T)=>{const E=M.index||1,I=T.index||1;return E-I}),n.value.configs.leftBtns=[...n.value.configs.leftBtns]}):f.value.open(x,S=>{S.visible=!0,Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.rightBtns.sort((M,T)=>{const E=M.index||1,I=T.index||1;return E-I}),n.value.configs.rightBtns=[...n.value.configs.rightBtns]})}function d(C){const x=C=="left"?n.value.configs.leftBtns.length:n.value.configs.rightBtns.length;let S={title:"新增"+x,name:"new_"+x,index:x,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{}};C=="left"?n.value.configs.leftBtns.push(S):n.value.configs.rightBtns.push(S),e.editor.widget(e.wid,n.value),r(C,S)}function h(C,x){const S=()=>{if(["add","delBatch","expData","impData","downTmpl"].includes(x.name))x.visible=!1,C=="left"?n.value.configs.leftBtns=[...n.value.configs.leftBtns]:n.value.configs.rightBtns=[...n.value.configs.rightBtns];else if(C=="left"){const M=[];n.value.configs.leftBtns.forEach(T=>{T.name!=x.name&&M.push(T)}),n.value.configs.leftBtns=M}else{const M=[];n.value.configs.rightBtns.forEach(T=>{T.name!=x.name&&M.push(T)}),n.value.configs.rightBtns=M}};J.Modal.confirm({title:"确认信息",content:"请确定删除该工具?",onOk:()=>{S()}})}const f=i.ref(null);function c(C){f.value.open(C,x=>{x.visible=!0,Object.keys(x).forEach(S=>{C[S]=x[S]}),n.value.configs.operation.btns.sort((S,M)=>{const T=S.index||1,E=M.index||1;return T-E}),n.value.configs.operation.btns=[...n.value.configs.operation.btns]})}function p(){const C=n.value.configs.operation.btns.length+1;let x={title:"新增"+C,name:"new_"+C,index:C,size:"small",visible:!0,type:"default",props:{block:!1,ghost:!1,danger:!1},event:{clickScript:"",titleScript:"",disableScript:"",visibleScript:""}};n.value.configs.operation.btns.push(x),e.editor.widget(e.wid,n.value),f.value.open(x,S=>{Object.keys(S).forEach(M=>{x[M]=S[M]}),n.value.configs.operation.btns=[...n.value.configs.operation.btns]})}function m(C){const x=()=>{if(["delete","view","edit"].includes(C.name))C.visible=!1,n.value.configs.operation.btns=[...n.value.configs.operation.btns];else{const S=[];n.value.configs.operation.btns.forEach(M=>{M.name!=C.name&&S.push(M)}),n.value.configs.operation.btns=S}};J.Modal.confirm({title:"确认信息",content:"请确定删除该操作?",onOk:()=>{x()}})}const b=i.computed(()=>e.editor?.dataModel(n.value.dataModel||"none")||{}),y=i.computed(()=>b.value.fields?.length?(b.value.fields.forEach(C=>{C.show||(C.show={}),C.show.list||(C.show.list={})}),b.value.fields):[]),w={mounted:C=>C.focus()},v=i.ref({});function k(){const C=Object.keys(v.value);if(C.length)for(let x in C){const S=y.value.filter(M=>M.name==x);if(S&&S[0]){let M=v.value[x];Object.keys(M).forEach(T=>{S[0].show||(S[0].show={}),S[0].show.list||(S[0].show.list={}),T=="showIndex"?S[0].show.list.index=M[T]:T=="showWidth"?S[0].show.list.width=M[T]:T=="fixed"?S[0].show.list.fixed=M[T]:T=="align"?S[0].show.list.align=M[T]:S[0][T]=M[T]})}}v.value={}}function O(C,x){k();const S={};x=="showIndex"?S[x]=C.show?.list?.index:x=="showWidth"?S[x]=C.show?.list?.width:x=="fixed"?S[x]=C.show?.list?.fixed:x=="align"?S[x]=C.show?.list?.align:S[x]=C[x]||"",v.value[C.name]=S}function g(C,x){if(!C||!x){v.value={};return}const S=v.value[C.name][x];C.show||(C.show={}),C.show.list||(C.show.list={}),x=="showIndex"?C.show.list.index=S:x=="showWidth"?C.show.list.width=S:x=="fixed"?C.show.list.fixed=S:x=="align"?C.show.list.align=S:C[x]=S,v.value={}}function u(C,x){return x=="showIndex"?C.show?.list?.index:x=="showWidth"?C.show?.list?.width:x=="fixed"?C.show?.list?.fixed:x=="align"?C.show?.list?.align:C[x]}function N(C,x){y.value.filter(M=>M.name==C.name).forEach(M=>{M[x]=!M[x]})}const V=i.ref({options:[{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:C=>{const x=V.value.options.filter(S=>S.value==C);return x[0]?x[0].label:C}});return(C,x)=>{const S=i.resolveComponent("a-divider"),M=i.resolveComponent("CloseOutlined"),T=i.resolveComponent("a-button"),E=i.resolveComponent("PlusOutlined"),I=i.resolveComponent("a-input"),L=i.resolveComponent("a-form-item"),A=i.resolveComponent("a-col"),U=i.resolveComponent("a-input-number"),P=i.resolveComponent("a-checkbox"),G=i.resolveComponent("a-row"),j=i.resolveComponent("a-select"),B=i.resolveComponent("ToolOutlined"),F=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",ar,[i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[8]||(x[8]=[i.createTextVNode("工具设置")])),_:1}),i.createElementVNode("div",rr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size,ref_for:!0},_.props||{},{onClick:D=>r("left",_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"bool-del",onClick:i.withModifiers(D=>h("left",_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","tool-add"]),size:"small",onClick:x[0]||(x[0]=_=>d("left"))},{default:i.withCtx(()=>[i.createVNode(E)]),_:1}),i.createVNode(T,{class:i.normalizeClass(["btn","tool-add","right"]),onClick:x[1]||(x[1]=_=>d("right")),size:"small"},{default:i.withCtx(()=>[i.createVNode(E)]),_:1}),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(o.value,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn","right",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size,ref_for:!0},_.props||{},{onClick:D=>r("right",_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"bool-del",onClick:i.withModifiers(D=>h("right",_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128))]),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[9]||(x[9]=[i.createTextVNode("操作设置")])),_:1}),n.value?.configs?.operation?(i.openBlock(),i.createBlock(G,{key:0},{default:i.withCtx(()=>[i.createVNode(A,{span:7},{default:i.withCtx(()=>[i.createVNode(L,{label:"操作标题"},{default:i.withCtx(()=>[i.createVNode(I,{value:n.value.configs.operation.title},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:5},{default:i.withCtx(()=>[i.createVNode(L,{label:"显示宽度",labelCol:{span:9}},{default:i.withCtx(()=>[i.createVNode(U,{value:n.value.configs.operation.width,"onUpdate:value":x[2]||(x[2]=_=>n.value.configs.operation.width=_)},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:6},{default:i.withCtx(()=>[i.createVNode(L,{label:"显示按钮数量",labelCol:{span:9}},{default:i.withCtx(()=>[i.createVNode(U,{value:n.value.configs.operation.count,"onUpdate:value":x[3]||(x[3]=_=>n.value.configs.operation.count=_)},null,8,["value"])]),_:1})]),_:1}),i.createVNode(A,{span:5},{default:i.withCtx(()=>[i.createVNode(L,{label:"是否显示"},{default:i.withCtx(()=>[i.createVNode(P,{checked:n.value.configs.operation.visible,"onUpdate:checked":x[4]||(x[4]=_=>n.value.configs.operation.visible=_)},null,8,["checked"])]),_:1})]),_:1})]),_:1})):i.createCommentVNode("",!0),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[10]||(x[10]=[i.createTextVNode("操作按钮")])),_:1}),n.value?.configs?.operation?(i.openBlock(),i.createElementBlock("div",dr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.value.configs.operation.btns,_=>(i.openBlock(),i.createBlock(T,i.mergeProps({key:_.name,class:["btn",_.name,!_.visible&&"deleted"],type:_.visible?_.type:"default",size:_.size||"small",ref_for:!0},_.props||{},{onClick:D=>c(_)}),i.createSlots({default:i.withCtx(()=>[i.createTextVNode(" "+i.toDisplayString(_.title)+" ",1),_.visible?(i.openBlock(),i.createBlock(M,{key:0,class:"btn-del",onClick:i.withModifiers(D=>m(_),["stop"])},null,8,["onClick"])):i.createCommentVNode("",!0)]),_:2},[_.icon?{name:"icon",fn:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(_.icon)))]),key:"0"}:void 0]),1040,["class","type","size","onClick"]))),128)),i.createVNode(T,{class:i.normalizeClass(["btn","btn-add"]),onClick:x[5]||(x[5]=_=>p()),size:"small"},{default:i.withCtx(()=>[i.createVNode(E)]),_:1})])):i.createCommentVNode("",!0),i.createVNode(S,{orientation:"left"},{default:i.withCtx(()=>x[11]||(x[11]=[i.createTextVNode("表头设置")])),_:1}),x[12]||(x[12]=i.createTextVNode(" 数据模型:")),i.createVNode(j,{class:"data-model-list",options:l.value,value:n.value.dataModel,"onUpdate:value":x[6]||(x[6]=_=>n.value.dataModel=_)},null,8,["options","value"]),i.createVNode(F,{columns:t.value,"data-source":y.value,bordered:"",scroll:{x:800},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:_})=>[["showIndex","showWidth","align","fixed"].includes(_.key)?(i.openBlock(),i.createElementBlock("span",cr,[i.createVNode(B),i.createTextVNode(" "+i.toDisplayString(_.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:_,record:D})=>[["showIndex","showWidth"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!v.value[D.name]||!Object.keys(v.value[D.name]).includes(_.dataIndex))&&!u(D,_.dataIndex)&&"empty"]),onClick:$=>O(D,_.dataIndex)},[v.value[D.name]&&Object.keys(v.value[D.name]).includes(_.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(U,{key:0,value:v.value[D.name][_.dataIndex],"onUpdate:value":$=>v.value[D.name][_.dataIndex]=$,onBlur:$=>g(D,_.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[w]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(u(D,_.dataIndex)),1)],64))],10,hr)):["isList","isQuery","isSort"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",fr,[i.createVNode(P,{checked:D[_.dataIndex],onClick:$=>N(D,_.dataIndex)},null,8,["checked","onClick"])])):["align","fixed"].includes(_.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!v.value[D.name]||!Object.keys(v.value[D.name]).includes(_.dataIndex))&&!u(D,_.dataIndex)&&"empty"]),onClick:$=>O(D,_.dataIndex)},[v.value[D.name]&&Object.keys(v.value[D.name]).includes(_.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(j,{key:0,value:D.show.list[_.dataIndex],"onUpdate:value":$=>D.show.list[_.dataIndex]=$,allowClear:!0,options:_.options,onBlur:x[7]||(x[7]=$=>g())},null,8,["value","onUpdate:value","options"])),[[w]]):(i.openBlock(),i.createElementBlock("span",pr,i.toDisplayString(_.showLabel(_.options,u(D,_.dataIndex))),1))],10,ur)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(ci,{ref_key:"btnSetting",ref:f,preset:["edit","view","add","delBatch","expData","impData","downTmpl"]},null,512)])}}}),[["__scopeId","data-v-c966c24c"]]);function nn(a){const e=a.toLowerCase().split("_"),t=[];t.push(e[0]);for(let n=1;n<e.length;n++){const l=e[n];l&&(t.push(l.charAt(0).toUpperCase()),l.length>1&&t.push(l.substring(1)))}return t.join("")}const gr={toHump:nn},kr={class:"unione-table-tools"},br={class:"unione-table-data"},yr={key:0,class:"unione-table-opts"},Cl=ne(i.defineComponent({__name:"tableList",props:{wid:{type:String,required:!1},editor:{type:Object,required:!1},widget:{type:Object,required:!1},loading:{type:Boolean,default:!1},pagination:{type:Object,required:!1},dataList:{type:Array,default(){return[]}},rowKey:{type:String,default:"id"}},emits:["edit","view","add","delete","delBatch","expData","impData","downTmpl","leftBtnClick","rightBtnClick","optBtnClick","btnClick","change"],setup(a,{expose:e,emit:t}){const n=Ie(),l=a,s=i.computed(()=>l.editor?.widget(l.wid)||l.widget||{}),o=i.computed(()=>s.value.props||{}),r=i.computed(()=>s.value.rowKey||l.rowKey||"id"),d=i.computed(()=>s.value.dsn?l.editor?.dataManager().use(s.value.dsn,"list"):null),h=i.computed(()=>{const E=l.dataList||[];return!E.length&&d.value?d.value.data().body||[]:E}),f=i.computed(()=>{if(s.value.operation==!1)return{visible:!1};const E=K.utils.obj.ext(s.value.operation||{},{title:"操作",width:200,count:2,btns:[],more:{title:"更多",visible:!0,trigger:"hover",size:"small",layout:"horizontal",items:[]}}),I=[];let L=(s.value.operation?.btns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A));if(L.forEach(A=>{I.push(A.name)}),I.includes("edit")||L.splice(0,0,{title:"编辑",name:"edit",type:"default",visible:!0}),I.includes("view")||L.splice(1,0,{title:"查看",name:"view",type:"default",visible:!0}),I.includes("delete")||L.push({title:"删除",name:"delete",type:"default",props:{danger:!0},visible:!0}),l.editor&&l.editor.type.value!="code"){const A=L.filter(P=>P.name=="edit")[0];if(A.visible&&(A.action||(A.action={}),A.action.type||(A.action.type="route"),!A.action.href)){const P=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form",G=l.editor.model.value;A.action.link=n.editPageUrl+"?psn="+P+"&model="+G+"&id={row."+l.rowKey+"}"}const U=L.filter(P=>P.name=="view")[0];if(U.visible&&(U.action||(U.action={}),U.action.type||(U.action.type="route"),!U.action.href)){const P=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form";U.action.link=n.viewPageUrl+"?psn="+P+"&model=view&id={row."+l.rowKey+"}"}}return L=L.filter(A=>A.visible!=!1).sort((A,U)=>{const P=A.index||1,G=U.index||1;return P-G}),E.count&&(L.length>E.count+1?(E.btns=L.slice(0,E.count),E.more.items=L.slice(E.count,L.length),E.more.visible=!0):(E.btns=L,E.more.visible=!1)),E}),c=i.computed(()=>{let E=[];s.value.columns?.length&&(E=[...s.value.columns]);const I=[];E.forEach((A,U)=>{A.dataIndex=A.name,A.convert&&(A.dataIndex=A.name+"Label",A.convertObj=new Ke(A.convert),A.customCell=(P,G,j)=>{const B=P[j.name];A.convertObj&&(P[j.dataIndex]==null||P[j.dataIndex]==null)&&B!=null&&B!=null&&(B+"").length>0&&(P[j.dataIndex]=B,A.convertObj.convert(B).then(F=>{F&&(P[j.dataIndex]=F)}))}),A.sort?.enable&&(A.sorter=!0,A.sort.multiple&&(A.sorter={},A.sorter.multiple=A.sort.multiple),A.sort.defoult&&(A.defaultSortOrder=A.sort.asc?"ascend":"descend")),A.customRender=({text:P})=>P||"--",A.fkey?.enable&&(A.fkey.labelName&&(A.dataIndex=nn(A.fkey.labelName)),A.fkey.labelTitle&&(A.title=A.fkey.labelTitle),A.customRender=({record:P,column:G})=>P&&P[G.name+"FEntry"]&&P[G.name+"FEntry"][G.dataIndex]||"--",A.fkey.fields?.forEach((P,G)=>{if(!P.name)return;const j=nn(P.name),B={fkName:A.name,title:P.title,name:j,dataIndex:P.name,width:P.width,index:P.index||U+G+1,customRender:({record:F,column:_})=>{if(F&&F[_.fkName+"FEntry"]){const D=F[_.fkName+"FEntry"][_.name];if(D)return P.convertObj&&P.convertObj.convert(D)||D}return"--"}};P.convert&&(P.convertObj=new Ke(P.convert)),I.push(B)}))}),I.forEach(A=>{E.splice(A.index,0,A)});const L=K.utils.obj.ext(s.value.rownum,{title:"序号",fixed:"left",align:"center",width:60,visible:!0});return L&&L.visible!=!1&&(L.customRender=A=>O.value?(O.value.current-1)*O.value.pageSize+A.index+1:A.index,E=[L,...E]),f.value&&f.value.visible!=!1&&E.push({fixed:"right",align:"center",...f.value,name:"operation"}),E}),p=i.computed(()=>{if(s.value.leftBtns===!1)return[];const E=[],I=[];if((s.value.leftBtns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A)).forEach(A=>{A.visible!=!1&&E.push(A),I.push(A.name),A.name=="delBatch"&&!g.value&&(A.visible=!1)}),!I.includes("add")){const A={visible:!0,title:"新增",icon:"PlusOutlined",size:"small",index:0,type:"primary",props:{danger:!1,block:!1,ghost:!1},name:"add"};E.splice(0,0,A)}if(!I.includes("delBatch")&&g.value){const A={visible:!0,title:"批量删除",icon:"DeleteOutlined",size:"small",index:1,type:"primary",props:{danger:!0,block:!1,ghost:!1},name:"delBatch"};E.splice(1,0,A)}if(l.editor&&l.editor.type.value!="code"){const A=E.filter(U=>U.name=="add")[0];if(A.visible&&(A.action||(A.action={}),A.action.type||(A.action.type="route"),!A.action.href)){const U=(l.editor.sn().endsWith(":list")?l.editor.sn().substring(0,l.editor.sn().length-5):l.editor.sn())+":form",P=l.editor.model.value;A.action.link=n.addPageUrl+"?psn="+U+"&model="+P}}return E});function m({btn:E,event:I}){if(n.isDebug&&console.log("unione table left btn click",E,I),E.name=="delBatch"){if(!u.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的记录!"});return}if(d.value){d.value.deleteByIds(u.value.selectedRowKeys).then(()=>{M(),S(!0)});return}J.Modal.confirm({title:"确认信息",content:"请确认是否要删除选中的("+u.value.selectedRowKeys.length+")数据",onOk:()=>{V("delBatch",{btn:E,event:I,keys:u.value.selectedRowKeys}),V("leftBtnClick",{btn:E,event:I,keys:u.value.selectedRowKeys}),V("btnClick",{btn:E,event:I,keys:u.value.selectedRowKeys})}});return}V(E.name,{btn:E,event:I}),V("leftBtnClick",{btn:E,event:I}),V("btnClick",{btn:E,event:I})}const b=i.computed(()=>{if(s.value.rightBtns===!1)return[];const E=[],I=[];if((s.value.rightBtns||[]).map(A=>(typeof A=="string"&&(A={name:A,visible:!1}),A)).forEach(A=>{A.visible!=!1&&E.push(A),I.push(A.name)}),!I.includes("impData")){const A={visible:!0,title:"导入",icon:"CloudUploadOutlined",size:"small",index:1,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"impData"};E.splice(1,0,A)}if(!I.includes("expData")){const A={visible:!0,title:"导出",icon:"CloudUploadOutlined",size:"small",index:2,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"expData"};E.splice(2,0,A)}if(!I.includes("downTmpl")){const A={visible:!0,icon:"CloudDownloadOutlined",size:"small",title:"模版",index:3,type:"default",props:{danger:!1,block:!1,ghost:!1},name:"downTmpl"};E.splice(3,0,A)}return E});function y({btn:E,event:I}){n.isDebug&&console.log("unione table right btn click",E,I),V(E.name,{btn:E,event:I}),V("rightBtnClick",{btn:E,event:I}),V("btnClick",{btn:E,event:I})}const w=i.computed(()=>({bordered:!0,size:"small",...s.value.attrs||{}})),v=i.ref({}),k=i.ref(null),O=i.computed(()=>K.utils.obj.ext(l.pagination||s.value.pagination,{showTotal:E=>"共"+E+"记录",pageSize:l.pagination?.pageSize||d.value?.data()?.pageSize||10,current:l.pagination?.current||d.value?.data()?.page||1,total:l.pagination?.total||d.value?.data()?.total||0,position:["bottomCenter"]})),g=i.computed(()=>typeof s.value.selection<"u"?s.value.selection:!0),u=i.ref({selectedRowKeys:[],selectedRowList:[],onChange:(E,I)=>{u.value.selectedRowKeys=E,u.value.selectedRowList=I},getCheckboxProps:E=>({disabled:E.checkable})}),N=["edit","view","add","delete","delBatch","impData","expData","downTmpl"],V=t;function C({btn:E,event:I},L){if(n.isDebug&&console.log("unione table opt btn click",E,I),E.name=="delete"){if(d.value){d.value.deleteByIds([L[r.value]]).then(()=>{M(),u.value.selectedRowKeys=u.value.selectedRowKeys.filter(A=>A!=L[r.value]),u.value.selectedRowList=u.value.selectedRowList.filter(A=>A[r.value]!=L[r.value])});return}J.Modal.confirm({title:"确认信息",content:"请确认是否要删除该记录?",onOk:()=>{V(E.name,{btn:E,event:I,row:L}),V("optBtnClick",{btn:E,event:I,row:L}),V("btnClick",{btn:E,event:I,row:L})}});return}V(E.name,{btn:E,event:I,row:L}),V("optBtnClick",{btn:E,event:I,row:L}),V("btnClick",{btn:E,event:I,row:L})}function x(E,I,L,A){console.log("tableChanged",E,I,L,A),k.value={page:E.current,pageSize:E.pageSize},L&&(Array.isArray(L)?(k.value.sorts=[],L.forEach(U=>{k.value.sorts.push({name:U.column.name,asc:U.order=="ascend"})})):L.column&&(k.value.sorts=[{name:L.column.name,asc:L.order=="ascend"}])),M(),V("change",{pagination:E,filters:I,sorter:L,event:A})}function S(E=!1){E?(u.value.selectedRowKeys=[],u.value.selectedRowList=[]):J.Modal.confirm({title:"确认信息",content:`确定要清除当前选中的(${u.value.selectedRowKeys.length})条数据?`,centered:!0,onOk:()=>{u.value.selectedRowKeys=[],u.value.selectedRowList=[]}})}function M(){if(d.value){const E={page:O.value.current,pageSize:O.value.pageSize,keywords:v.value.keywords,body:v.value.params||{}};k.value?.page&&(E.page=k.value.page),k.value?.pageSize&&(E.pageSize=k.value.pageSize),k.value?.sorts&&(E.sorts=k.value.sorts),console.log("dataStorage find params",E),d.value.find(E)}}i.onMounted(()=>{c.value?.forEach(E=>{E.sort?.enable&&E.sort.defoult&&(k.value||(k.value={},k.value.sorts||(k.value.sorts=[]),k.value.sorts.push({name:E.name,asc:E.sort.asc==!0})))}),l.editor?.ebus.$on("table-list-search",E=>{console.log("table-list-search",E),v.value=E||{},M()}),l.editor?.ebus.$on("table-list-reset",()=>{console.log("table-list-reset"),v.value={},M(),S(!0)}),l.editor?.ebus.$on("table-list-reload",()=>{console.log("table-list-reload"),M()})});function T(){return{keys:u.value.selectedRowKeys,rows:u.value.selectedRowList}}return e({getSelected:T,clearSelected:S}),(E,I)=>{const L=i.resolveComponent("unione-btn"),A=i.resolveComponent("DownOutlined"),U=i.resolveComponent("a-button"),P=i.resolveComponent("a-dropdown"),G=i.resolveComponent("a-table");return i.openBlock(),i.createBlock(ht,{class:"unione-table-list",model:l.editor?.model.value,"setting-title":"列表设置"},i.createSlots({default:i.withCtx(()=>[i.createElementVNode("div",kr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(p.value,j=>(i.openBlock(),i.createBlock(L,{key:j.name,class:"btn",widget:j,editor:a.editor,onClick:m,preset:N,ctx:{sltKeys:u.value.selectedRowKeys,sltRows:u.value.selectedRowList}},null,8,["widget","editor","ctx"]))),128)),u.value.selectedRowKeys.length?(i.openBlock(),i.createElementBlock("span",{key:0,class:"selected-info",onClick:I[0]||(I[0]=j=>S())},"当前选中记录("+i.toDisplayString(u.value.selectedRowKeys.length)+")",1)):i.createCommentVNode("",!0),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(b.value,j=>(i.openBlock(),i.createBlock(L,{key:j.name,class:"btn right",widget:j,editor:a.editor,onClick:y,preset:N,ctx:{sltKeys:u.value.selectedRowKeys,sltRows:u.value.selectedRowList}},null,8,["widget","editor","ctx"]))),128))]),i.createElementVNode("div",br,[c.value&&c.value.length?(i.openBlock(),i.createBlock(G,i.mergeProps({key:0,columns:c.value,rowKey:r.value,"data-source":h.value,"row-selection":g.value?u.value:null,scroll:{x:o.value.scrollX||"max-content",y:o.value.scrollY},pagination:O.value,onChange:x},w.value),{bodyCell:i.withCtx(({column:j,record:B})=>[j.name==="operation"?(i.openBlock(),i.createElementBlock("div",yr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(f.value.btns,F=>(i.openBlock(),i.createBlock(L,{key:F.name,class:"opt",widget:F,editor:a.editor,onClick:_=>C(_,B),preset:N,ctx:{row:B}},null,8,["widget","editor","onClick","ctx"]))),128)),f.value.more?.visible!=!1&&f.value.more.items?.length?(i.openBlock(),i.createBlock(P,{key:0,trigger:[f.value.more.trigger||"hover"],class:i.normalizeClass(["opt-more",f.value.more.size||"small"])},{overlay:i.withCtx(()=>[i.createElementVNode("div",{class:i.normalizeClass(["opt-more-overlay",f.value.more.layout])},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(f.value.more.items,F=>(i.openBlock(),i.createBlock(L,{key:F.name,class:"item",widget:F,editor:a.editor,onClick:_=>C(_,B),type:"text",preset:N,ctx:{row:B}},null,8,["widget","editor","onClick","ctx"]))),128))],2)]),default:i.withCtx(()=>[i.createVNode(U,null,{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(f.value.more.title)+" ",1),i.createVNode(A)]),_:1})]),_:2},1032,["trigger","class"])):i.createCommentVNode("",!0)])):i.createCommentVNode("",!0)]),_:1},16,["columns","rowKey","data-source","row-selection","scroll","pagination"])):i.createCommentVNode("",!0)])]),_:2},[l.editor&&l.wid?{name:"widget-setting",fn:i.withCtx(()=>[i.createVNode(mr,{editor:l.editor,wid:l.wid},null,8,["editor","wid"])]),key:"0"}:void 0]),1032,["model"])}}}),[["__scopeId","data-v-d11fa152"]]),wr={class:"page-setting-dialog"},jt=i.defineComponent({__name:"page",props:{settingTitle:{type:String,default:"页面设置"},editor:{type:Object,required:!1}},emits:["setting","saving"],setup(a,{emit:e}){const t=a,n=i.computed(()=>t.editor?.model?.value),l=K.useSession(),s=i.computed(()=>l.getPrincipal()),o=i.ref(!1);i.provide("closeSetting",()=>{t.editor?.save().then(p=>{o.value=!1})});function r(){o.value=!0}function d(){t.editor?.save().then(p=>{console.log("res",p)})}function h(){t.editor?.save().then(p=>{console.log("res",p)})}const f=i.ref("");function c(p){f.value||(f.value=n.value),p?t.editor?.setModel("edit"):t.editor?.setModel(f.value)}return(p,m)=>{const b=i.resolveComponent("SettingOutlined"),y=i.resolveComponent("a-tooltip"),w=i.resolveComponent("SaveOutlined"),v=i.resolveComponent("FormOutlined"),k=i.resolveComponent("StopOutlined"),O=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-page",n.value])},[n.value=="edit"&&p.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:0,title:a.settingTitle},{default:i.withCtx(()=>[i.createVNode(b,{class:"page-setting",onClick:r})]),_:1},8,["title"])):i.createCommentVNode("",!0),n.value=="edit"&&p.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:1,title:"保存页面"},{default:i.withCtx(()=>[i.createVNode(w,{class:"btn-save",onClick:d})]),_:1})):i.createCommentVNode("",!0),n.value!="edit"&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:2,title:"编辑页面"},{default:i.withCtx(()=>[i.createVNode(v,{class:"btn-edit",onClick:m[0]||(m[0]=g=>c(!0))})]),_:1})):i.createCommentVNode("",!0),n.value=="edit"&&p.$slots["page-setting"]&&s.value?.userRoles?.includes("FORM-ADMIN")?(i.openBlock(),i.createBlock(y,{key:3,title:"退出编辑"},{default:i.withCtx(()=>[i.createVNode(k,{class:"btn-edit",onClick:m[1]||(m[1]=g=>c(!1))})]),_:1})):i.createCommentVNode("",!0),i.renderSlot(p.$slots,"default"),n.value=="edit"?(i.openBlock(),i.createBlock(O,{key:4,title:t.settingTitle,open:o.value,"onUpdate:open":m[2]||(m[2]=g=>o.value=g),centered:"",width:"85%",onOk:h},{default:i.withCtx(()=>[i.createElementVNode("div",wr,[i.renderSlot(p.$slots,"page-setting")])]),_:3},8,["title","open"])):i.createCommentVNode("",!0)],2)}}}),xr={class:"unione-props-setting data-field-manage"},vr={key:0},Cr={key:1},Sr={key:2},Nr={key:3},Br={key:4},Or={key:5},Vr={key:6},_r=["onClick"],Mr=["onClick"],Tr=["onClick"],Ar={key:1},Er=ne(i.defineComponent({__name:"dataFieldMange",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:p})=>p+1},{title:"名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"标题",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"数据类型",dataIndex:"dataType",key:"dataType",width:"80px",align:"center"},{title:"长度",dataIndex:"dataLen",key:"dataLen",width:"60px",align:"center"},{title:"小数点",dataIndex:"dataPrec",key:"dataPrec",width:"60px",align:"center"},{title:"默认值",dataIndex:"defaultValue",key:"defaultValue",width:"60px",align:"center"},{title:"主键",dataIndex:"isPk",key:"isPk",width:"40px",align:"center"},{title:"外键",dataIndex:"isFk",key:"isFk",width:"30px",align:"center"},{title:"非空",dataIndex:"isNull",key:"isNull",width:"30px",align:"center"},{title:"同步",dataIndex:"syncDbEnable",key:"syncDbEnable",width:"30px",align:"center"},{title:"备注",dataIndex:"descs",key:"descs",width:"140px",align:"center"}]),t=i.useModel(a,"modelValue"),n=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:p=>{p.forEach(m=>{n.value.selectedRowKeys.includes(m)||n.value.selectedRowKeys.push(m);const b=[];t.value.forEach(y=>{!p.includes(y.name)&&n.value.selectedRowKeys.includes(y.name)&&b.push(y.name)}),b.length&&(n.value.selectedRowKeys=n.value.selectedRowKeys.filter(y=>!b.includes(y)))})}}),l={mounted:p=>p.focus()},s=i.ref({});function o(){const p=Object.keys(s.value);if(p.length)for(let m in p){const b=t.value.filter(y=>y.name==m);if(b&&b[0]){let y=s.value[m];Object.keys(y).forEach(w=>{b[0][w]=y[w]})}}s.value={}}function r(p,m){o();const b={};b[m]=p[m]||"",s.value[p.name]=b}function d(p,m){if(!p||!m){s.value={};return}const b=s.value[p.name][m];if(m=="name"&&t.value.filter(w=>w[m]==b&&w.name!=p.name).length>0){J.Modal.warn({title:"提示信息",content:"字段名称["+b+"]已存在"});return}p[m]=b,s.value={}}function h(p,m){t.value.filter(y=>y.name==p.name).forEach(y=>{y[m]=!y[m]})}function f(){if(o(),t.value.filter(b=>b.name=="new_").length>0){s.value.new_={name:"new_"};return}const m={title:"",name:"new_",isPk:!1};t.value.push(m),s.value[m.name]={name:"new_"}}function c(){if(!n.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的字段!"});return}J.Modal.confirm({title:"确认信息",content:"确定要删除选中的["+n.value.selectedRowKeys.length+"]字段么?",onOk:()=>{t.value=t.value.filter(p=>!n.value.selectedRowKeys.includes(p.name)),n.value.selectedRowKeys=[]}})}return(p,m)=>{const b=i.resolveComponent("a-button"),y=i.resolveComponent("a-tooltip"),w=i.resolveComponent("a-input"),v=i.resolveComponent("a-input-number"),k=i.resolveComponent("a-select-option"),O=i.resolveComponent("a-select"),g=i.resolveComponent("a-checkbox"),u=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",xr,[i.createVNode(b,{class:"btn btn-add",type:"primary",onClick:f,size:"small"},{default:i.withCtx(()=>m[1]||(m[1]=[i.createTextVNode("新增")])),_:1}),i.createVNode(b,{class:"btn btn-delete",type:"primary",danger:"",onClick:c,size:"small"},{default:i.withCtx(()=>m[2]||(m[2]=[i.createTextVNode(" 删除 ")])),_:1}),i.createVNode(u,{columns:e.value,"data-source":t.value,pagination:!1,bordered:"","row-selection":n.value,scroll:{x:1150},"row-key":"name",size:"small",sticky:""},{headerCell:i.withCtx(({column:N})=>[N.key==="name"?(i.openBlock(),i.createElementBlock("span",vr,[m[3]||(m[3]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="title"?(i.openBlock(),i.createElementBlock("span",Cr,[m[4]||(m[4]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="descs"?(i.openBlock(),i.createElementBlock("span",Sr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataLen"?(i.openBlock(),i.createElementBlock("span",Nr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataPrec"?(i.openBlock(),i.createElementBlock("span",Br,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="defaultValue"?(i.openBlock(),i.createElementBlock("span",Or,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="dataType"?(i.openBlock(),i.createElementBlock("span",Vr,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(N.title),1)])):i.createCommentVNode("",!0),N.key==="isPk"?(i.openBlock(),i.createBlock(y,{key:7,title:"至少配置一个主键字段"},{default:i.withCtx(()=>[m[5]||(m[5]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="isFk"?(i.openBlock(),i.createBlock(y,{key:8,title:"是否是外键字段"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="isNull"?(i.openBlock(),i.createBlock(y,{key:9,title:"是否允许为空"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0),N.key==="syncDbEnable"?(i.openBlock(),i.createBlock(y,{key:10,title:"是否同步到数据库"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(N.title),1)]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:N,text:V,record:C})=>[["name","title","descs","defaultValue"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(w,{key:0,value:s.value[C.name][N.dataIndex],"onUpdate:value":x=>s.value[C.name][N.dataIndex]=x,onBlur:x=>d(C,N.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V||" "),1)],64))],10,_r)):i.createCommentVNode("",!0),["dataLen","dataPrec"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(v,{key:0,value:s.value[C.name][N.dataIndex],"onUpdate:value":x=>s.value[C.name][N.dataIndex]=x,onBlur:x=>d(C,N.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V||" "),1)],64))],10,Mr)):["dataType"].includes(N.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[C.name]||!Object.keys(s.value[C.name]).includes(N.dataIndex))&&!V&&"empty"]),onClick:x=>r(C,N.dataIndex)},[s.value[C.name]&&Object.keys(s.value[C.name]).includes(N.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(O,{key:0,value:C[N.dataIndex],"onUpdate:value":x=>C[N.dataIndex]=x,onBlur:m[0]||(m[0]=x=>d())},{default:i.withCtx(()=>[i.createVNode(k,{key:"String",value:"String"}),i.createVNode(k,{key:"Long",value:"Long"}),i.createVNode(k,{key:"Short",value:"Short"}),i.createVNode(k,{key:"Integer",value:"Integer"}),i.createVNode(k,{key:"Float",value:"Float"}),i.createVNode(k,{key:"Double",value:"Double"}),i.createVNode(k,{key:"Date",value:"Date"}),i.createVNode(k,{key:"Timestamp",value:"Timestamp"})]),_:2},1032,["value","onUpdate:value"])),[[l]]):(i.openBlock(),i.createElementBlock("span",Ar,i.toDisplayString(V),1))],10,Tr)):["syncDbEnable","isFk","isPk"].includes(N.dataIndex)?(i.openBlock(),i.createBlock(g,{key:3,checked:C[N.dataIndex],onClick:x=>h(C,N.dataIndex)},null,8,["checked","onClick"])):["isNull"].includes(N.dataIndex)?(i.openBlock(),i.createBlock(g,{key:4,checked:!C[N.dataIndex],onClick:x=>h(C,N.dataIndex)},null,8,["checked","onClick"])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])])}}}),[["__scopeId","data-v-f6307a23"]]),Ir={class:"unione-props-setting data-field-setting"},Dr={key:0},Pr=["onClick"],Fr={class:"field-txt"},$r=["onClick"],Rr={key:1,class:"field-txt"},Lr=["onClick"],jr={key:1},zr=["onClick"],qr={key:0,class:"field-txt"},Ur={key:4,class:"edit-field"},Wr={key:0},Hr=["onClick"],Kr=ne(i.defineComponent({__name:"dataFieldSetting",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:v})=>v+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"isForm",key:"isForm",width:"40px",align:"center"},{title:"详情",dataIndex:"isView",key:"isView",width:"40px",align:"center"},{title:"列表",dataIndex:"isList",key:"isList",width:"40px",align:"center"},{title:"排序",dataIndex:"isSort",key:"isSort",width:"40px",align:"center"},{title:"查询",dataIndex:"isQuery",key:"isQuery",width:"40px",align:"center"},{title:"查询类型",dataIndex:"queryType",key:"queryType",width:"60px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),t=i.useModel(a,"modelValue"),n={mounted:v=>v.focus()},l=i.ref({});function s(){const v=Object.keys(l.value);if(v.length)for(let k in v){const O=t.value.filter(g=>g.name==k);if(O&&O[0]){let g=l.value[k];Object.keys(g).forEach(u=>{u=="convertName"?(O[0].convert||(O[0].convert={}),O[0].convert.type=g[u]):O[0][u]=g[u]})}}l.value={}}function o(v,k){s();const O={};k=="convertName"?(v.convert||(v.convert={}),O[k]=v.convert?.type):O[k]=v[k]||"",l.value[v.name]=O}function r(v,k){{l.value={};return}}function d(v,k){t.value.filter(g=>g.name==v.name).forEach(g=>{g[k]=!g[k]})}const h=i.ref({title:"列头设置",prop:"isList",visible:!1,field:{},show:{},toSetting:()=>{h.value.visible=!1}});function f(v,k){const O=t.value.filter(u=>u.name==v.name);O.forEach(u=>{k!="isSort"?u[k]=!0:u[k]=!u[k]});const g=O[0];if(!(!g||k=="isSort")){switch(h.value.prop=k,h.value.field=v,g.show||(g.show={}),k){case"isQuery":g.show.query||(g.show.query={}),h.value.show=g.show.query,h.value.title=`查询设置/${v.title}(${v.name})`;break;case"isForm":g.show.form||(g.show.form={}),h.value.show=g.show.form,h.value.title=`表单设置/${v.title}(${v.name})`;break;case"isView":g.show.view||(g.show.view={}),h.value.show=g.show.view,h.value.title=`详情设置/${v.title}(${v.name})`;break;case"isList":g.show.list||(g.show.list={}),h.value.show=g.show.list,h.value.title=`列头设置/${v.title}(${v.name})`;break}h.value.visible=!0}}const c=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:v=>{const k=c.value.options.filter(O=>O.value==v);return k[0]?k[0].label:v}}),p=i.ref({visible:!1,field:{},props:{},showInfo:v=>{let k="";return v.rules&&(k=v.rules.filter(O=>O.enable).length||""),k&&(k="("+k+")"),k},toSetting:()=>{const v=p.value.props,k={name:"range",trigger:v.trigger,whitespace:v.whitespace,message:v.rangeMessage};v.rangeMin!=null&&v.rangeMin!=null&&(k.min=v.rangeMin,k.enable=!0),v.rangeMax!=null&&v.rangeMax!=null&&(k.max=v.rangeMax,k.enable=!0);const O={name:"reg",trigger:v.trigger,whitespace:v.whitespace,message:v.regMessage};v.regExpress&&(O.pattern=v.regExpress,O.enable=!0),p.value.field.rules=[k,O],p.value.visible=!1,p.value.props={},console.log("rule",p.value.field.rules)}});function m(v){p.value.visible=!0,p.value.field=v;const k=v.rules||[],O={trigger:"change",whitespace:!0};k.forEach(g=>{g.name=="reg"&&(O.trigger=g.trigger,O.whitespace=g.whitespace,O.regExpress=g.pattern,O.regMessage=g.message),g.name=="range"&&(O.rangeMin=g.min,O.rangeMax=g.max,O.rangeMessage=g.message)}),p.value.props=O}const b=i.ref({visible:!1,field:{},props:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-textarea",label:"文本域"},{value:"a-input",label:"文本框"},{value:"a-checkbox",label:"多选框"},{value:"a-radio",label:"单选框"},{value:"a-input-number",label:"数值框"},{value:"a-select",label:"下拉框"},{value:"a-tree-select",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-switch",label:"开关"},{value:"a-slider",label:"滑块"}],widgetName:v=>{const k=b.value.widgets.filter(O=>O.value==v);return k[0]?k[0].label:v},toSetting:()=>{}}),y=i.ref({visible:!1,field:{},convert:{},optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],toAddOption:()=>{y.value.convert.options||(y.value.convert.options=[]),y.value.convert.options.push({label:"",value:""})},toDelOption:(v,k)=>{y.value.convert.options.splice(v,1)},toSetting:()=>{y.value.visible=!1}});function w(v){y.value.visible=!0,y.value.field=v,y.value.convert=v.convert||{}}return(v,k)=>{const O=i.resolveComponent("ToolOutlined"),g=i.resolveComponent("a-button"),u=i.resolveComponent("a-select"),N=i.resolveComponent("a-checkbox"),V=i.resolveComponent("a-table"),C=i.resolveComponent("a-input-number"),x=i.resolveComponent("a-form-item"),S=i.resolveComponent("a-input"),M=i.resolveComponent("a-form"),T=i.resolveComponent("a-modal"),E=i.resolveComponent("a-col"),I=i.resolveComponent("a-row"),L=i.resolveComponent("a-select-option"),A=i.resolveComponent("a-divider"),U=i.resolveComponent("a-checkbox-group");return i.openBlock(),i.createElementBlock("div",Ir,[i.createVNode(V,{columns:e.value,"data-source":t.value,bordered:"",scroll:{x:1e3},pagination:!1,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:P})=>[["widget","queryType","rules","convertName"].includes(P.key)?(i.openBlock(),i.createElementBlock("span",Dr,[i.createVNode(O),i.createTextVNode(" "+i.toDisplayString(P.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:P,text:G,record:j})=>[["rules"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!p.value.showInfo(j)&&"empty"]),onClick:B=>m(j)},[i.createElementVNode("span",Fr,i.toDisplayString(p.value.showInfo(j)),1),p.value.showInfo(j)?(i.openBlock(),i.createBlock(g,{key:0,type:"link"},{default:i.withCtx(()=>k[22]||(k[22]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Pr)):["widget"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!G&&"empty"]),onClick:B=>o(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(u,{key:0,value:j[P.dataIndex],"onUpdate:value":B=>j[P.dataIndex]=B,allowClear:!0,options:b.value.widgets,onBlur:k[0]||(k[0]=B=>r())},null,8,["value","onUpdate:value","options"])),[[n]]):(i.openBlock(),i.createElementBlock("span",Rr,i.toDisplayString(b.value.widgetName(G)),1))],10,$r)):["queryType"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock(i.Fragment,{key:2},[j.isQuery?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!G&&"empty"]),onClick:B=>o(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(u,{key:0,value:j[P.dataIndex],"onUpdate:value":B=>j[P.dataIndex]=B,allowClear:!0,options:c.value.options,onBlur:k[1]||(k[1]=B=>r())},null,8,["value","onUpdate:value","options"])),[[n]]):(i.openBlock(),i.createElementBlock("span",jr,i.toDisplayString(c.value.showLabel(G)),1))],10,Lr)):i.createCommentVNode("",!0)],64)):["convertName"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:3,class:i.normalizeClass(["edit-field",(!l.value[j.name]||!Object.keys(l.value[j.name]).includes(P.dataIndex))&&!j.convert?.type&&"empty"]),onClick:B=>o(j,P.dataIndex)},[l.value[j.name]&&Object.keys(l.value[j.name]).includes(P.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(u,{key:0,value:j.convert.type,"onUpdate:value":B=>j.convert.type=B,options:[{value:"dict",label:"字典"},{value:"option",label:"静态"}],allowClear:!0,onBlur:k[2]||(k[2]=B=>r())},null,8,["value","onUpdate:value"])),[[n]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[j.convert?.type?(i.openBlock(),i.createElementBlock("span",qr,i.toDisplayString(j.convert.type=="dict"?"字典":"静态"),1)):i.createCommentVNode("",!0),j.convert?.type?(i.openBlock(),i.createBlock(g,{key:1,type:"link",onClick:i.withModifiers(B=>w(j),["stop"])},{default:i.withCtx(()=>k[23]||(k[23]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,zr)):["isQuery","isForm","isView","isList","isSort"].includes(P.dataIndex)?(i.openBlock(),i.createElementBlock("div",Ur,[i.createVNode(N,{checked:j[P.dataIndex],onClick:B=>d(j,P.dataIndex)},null,8,["checked","onClick"]),i.createVNode(g,{type:"link",onClick:B=>f(j,P.dataIndex)},{default:i.withCtx(()=>k[24]||(k[24]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(T,{visible:h.value.visible,"onUpdate:visible":k[9]||(k[9]=P=>h.value.visible=P),title:h.value.title,onOk:h.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:h.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(x,{label:"显示顺序"},{default:i.withCtx(()=>[i.createVNode(C,{value:h.value.show.index,"onUpdate:value":k[3]||(k[3]=P=>h.value.show.index=P)},null,8,["value"])]),_:1}),["isQuery"].includes(h.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(x,{key:0,label:"显示宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.width,"onUpdate:value":k[4]||(k[4]=P=>h.value.show.width=P)},null,8,["value"])]),_:1})),["isForm","isView"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:1,label:"标题宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.labelWidth,"onUpdate:value":k[5]||(k[5]=P=>h.value.show.labelWidth=P)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isForm","isView"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:2,label:"控件宽度"},{default:i.withCtx(()=>[i.createVNode(S,{value:h.value.show.valueWidth,"onUpdate:value":k[6]||(k[6]=P=>h.value.show.valueWidth=P)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:3,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(u,{value:h.value.show.fixed,"onUpdate:value":k[7]||(k[7]=P=>h.value.show.fixed=P),options:[{value:"",label:"无"},{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["isList"].includes(h.value.prop)?(i.openBlock(),i.createBlock(x,{key:4,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(u,{value:h.value.show.align,"onUpdate:value":k[8]||(k[8]=P=>h.value.show.align=P),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(T,{visible:y.value.visible,"onUpdate:visible":k[11]||(k[11]=P=>y.value.visible=P),title:y.value.convert.type=="dict"?"字典设置":"选项设置",onOk:y.value.toSetting},{default:i.withCtx(()=>[y.value.convert.type!="dict"?(i.openBlock(),i.createElementBlock("div",Wr,[i.createVNode(g,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:y.value.toAddOption},{default:i.withCtx(()=>k[25]||(k[25]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(V,{columns:y.value.optionColumn,"data-source":y.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:P,text:G,record:j,index:B})=>[P.dataIndex==="label"?(i.openBlock(),i.createBlock(S,{key:0,value:j.label,"onUpdate:value":F=>j.label=F,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),P.dataIndex==="value"?(i.openBlock(),i.createBlock(S,{key:1,value:j.value,"onUpdate:value":F=>j.value=F,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),P.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:F=>y.value.toDelOption(B,j)},"删除",8,Hr)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])])):i.createCommentVNode("",!0),y.value.convert.type=="dict"?(i.openBlock(),i.createBlock(M,{key:1,model:y.value.convert,name:"basic","label-col":{span:8},"wrapper-col":{span:16},autocomplete:"off"},{default:i.withCtx(()=>[i.createVNode(I,{type:"flex",style:{width:"100%"}},{default:i.withCtx(()=>[i.createVNode(E,{span:24,order:1},{default:i.withCtx(()=>[i.createVNode(x,{label:"字典名称:"},{default:i.withCtx(()=>[i.createVNode(S,{value:y.value.convert.dict,"onUpdate:value":k[10]||(k[10]=P=>y.value.convert.dict=P)},null,8,["value"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])):i.createCommentVNode("",!0)]),_:1},8,["visible","title","onOk"]),i.createVNode(T,{visible:b.value.visible,"onUpdate:visible":k[13]||(k[13]=P=>b.value.visible=P),title:"控件设置",onOk:b.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:b.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off"},{default:i.withCtx(()=>[b.value.field.widget=="a-select"?(i.openBlock(),i.createBlock(x,{key:0,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(u,{value:b.value.props.mode,"onUpdate:value":k[12]||(k[12]=P=>b.value.props.mode=P),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(L,{value:"multiple"},{default:i.withCtx(()=>k[26]||(k[26]=[i.createTextVNode("多选")])),_:1}),i.createVNode(L,{value:"tags"},{default:i.withCtx(()=>k[27]||(k[27]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(T,{visible:p.value.visible,"onUpdate:visible":k[21]||(k[21]=P=>p.value.visible=P),title:"规则设置",onOk:p.value.toSetting},{default:i.withCtx(()=>[i.createVNode(M,{model:p.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>k[28]||(k[28]=[i.createTextVNode("基本设置")])),_:1}),i.createVNode(x,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(U,{value:p.value.props.trigger,"onUpdate:value":k[14]||(k[14]=P=>p.value.props.trigger=P),options:["change","blur"]},null,8,["value"])]),_:1}),p.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(x,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(N,{value:p.value.props.whitespace,"onUpdate:value":k[15]||(k[15]=P=>p.value.props.whitespace=P),checked:p.value.props.whitespace},{default:i.withCtx(()=>k[29]||(k[29]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["value","checked"])]),_:1})),i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>k[30]||(k[30]=[i.createTextVNode("数值区间")])),_:1}),i.createVNode(x,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(C,{value:p.value.props.rangeMin,"onUpdate:value":k[16]||(k[16]=P=>p.value.props.rangeMin=P)},null,8,["value"]),k[31]||(k[31]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(C,{value:p.value.props.rangeMax,"onUpdate:value":k[17]||(k[17]=P=>p.value.props.rangeMax=P)},null,8,["value"])]),_:1}),i.createVNode(x,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(S,{value:p.value.props.rangeMessage,"onUpdate:value":k[18]||(k[18]=P=>p.value.props.rangeMessage=P)},null,8,["value"])]),_:1}),i.createVNode(A,{orientation:"left"},{default:i.withCtx(()=>k[32]||(k[32]=[i.createTextVNode("正则验证")])),_:1}),i.createVNode(x,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(S,{value:p.value.props.regExpress,"onUpdate:value":k[19]||(k[19]=P=>p.value.props.regExpress=P)},null,8,["value"])]),_:1}),i.createVNode(x,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(S,{value:p.value.props.regMessage,"onUpdate:value":k[20]||(k[20]=P=>p.value.props.regMessage=P)},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-ef9b9849"]]),Qr={class:"unione-props-setting data-field"},Gr=ne(i.defineComponent({__name:"dataField",props:i.mergeModels({filter:{type:Array,default(){return[]}}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(a){const e=i.useModel(a,"modelValue");return(t,n)=>{const l=i.resolveComponent("OrderedListOutlined"),s=i.resolveComponent("a-tab-pane"),o=i.resolveComponent("ToolOutlined"),r=i.resolveComponent("a-tabs");return i.openBlock(),i.createElementBlock("div",Qr,[i.createVNode(r,null,{default:i.withCtx(()=>[i.createVNode(s,{key:"field-mange"},{tab:i.withCtx(()=>[i.createVNode(l),n[2]||(n[2]=i.createTextVNode("字段管理 "))]),default:i.withCtx(()=>[i.createVNode(Er,{modelValue:e.value,"onUpdate:modelValue":n[0]||(n[0]=d=>e.value=d)},null,8,["modelValue"])]),_:1}),i.createVNode(s,{key:"field-setting"},{tab:i.withCtx(()=>[i.createVNode(o),n[3]||(n[3]=i.createTextVNode("字段设置 "))]),default:i.withCtx(()=>[i.createVNode(Kr,{modelValue:e.value,"onUpdate:modelValue":n[1]||(n[1]=d=>e.value=d)},null,8,["modelValue"])]),_:1})]),_:1})])}}}),[["__scopeId","data-v-008d1148"]]),Yr={key:0,class:"data-model-list"},Xr=["onClick"],Jr=ne(i.defineComponent({__name:"dataDefine",props:{limit:{type:Number,default:100},editor:{type:Object,required:!0}},setup(a,{expose:e}){const t=i.computed(()=>l.editor.dataModels()),n=i.ref({sn:"new_",title:"新建数据",fields:[]});i.onMounted(()=>{t.value&&t.value[0]&&(n.value=t.value[0])});const l=a;function s(c){n.value=c}function o(){if(t.value.length>=l.limit){J.Modal.warn({title:"提示信息",content:"数据模型数量超出限制!"});return}const c=sa.v4(),p={sn:c,title:"新建数据",name:"new_",fields:[]};n.value=p,console.log("data model added",p),l.editor.dataModel(c,p)}const r={title:[{required:!0,message:"数据标题不能为空",trigger:"change"}],name:[{required:!0,message:"数据名称不能为空",trigger:"change"}],url:[{required:!0,message:"数据URl不能为空",trigger:"change"}]},d=i.ref(),h=i.inject("closeSetting");function f(){d.value.validate().then(c=>{h&&h()})}return e({toSaving:f}),(c,p)=>{const m=i.resolveComponent("a-input"),b=i.resolveComponent("a-form-item"),y=i.resolveComponent("a-textarea"),w=i.resolveComponent("a-form");return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["unione-props-setting","data-define",l.limit<=1&&"center"])},[l.limit>1?(i.openBlock(),i.createElementBlock("div",Yr,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(t.value,v=>(i.openBlock(),i.createElementBlock("div",{key:v.sn,class:i.normalizeClass(["title",n.value&&n.value.sn==v.sn&&"slt"]),onClick:k=>s(v)},i.toDisplayString(v.title),11,Xr))),128)),i.createElementVNode("div",{class:"title btn-add",onClick:o},"+")])):i.createCommentVNode("",!0),i.createElementVNode("div",{class:i.normalizeClass(["data-model-form",l.limit<=1&&"center"])},[i.createVNode(w,{ref_key:"formObj",ref:d,rules:r,model:n.value,"label-col":{span:4},"wrapper-col":{span:20}},{default:i.withCtx(()=>[i.createVNode(b,{label:"数据标题",name:"title",required:""},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.title,"onUpdate:value":p[0]||(p[0]=v=>n.value.title=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据名称",name:"name",required:""},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.name,"onUpdate:value":p[1]||(p[1]=v=>n.value.name=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据URL",name:"url",required:"",tooltip:"数据请求url,统一使用post请求,保存接口:url/save,修改接口:url/update,查询接口:url/find,删除接口:url/delete,详情接口:url/detail"},{default:i.withCtx(()=>[i.createVNode(m,{value:n.value.url,"onUpdate:value":p[2]||(p[2]=v=>n.value.url=v)},null,8,["value"])]),_:1}),i.createVNode(b,{label:"数据说明",name:"descs"},{default:i.withCtx(()=>[i.createVNode(y,{value:n.value.descs,"onUpdate:value":p[3]||(p[3]=v=>n.value.descs=v)},null,8,["value"])]),_:1})]),_:1},8,["model"]),i.createVNode(Gr,{modelValue:n.value.fields,"onUpdate:modelValue":p[4]||(p[4]=v=>n.value.fields=v)},null,8,["modelValue"])],2)],2)}}}),[["__scopeId","data-v-6be2cc50"]]),Zr={class:"unione-props-setting unione-page-setting"},zt=ne(i.defineComponent({__name:"pageSetting",props:{editor:{type:Object,required:!0}},setup(a){const e=a,t=i.ref({});return i.onMounted(()=>{t.value=e.editor.define.value}),(n,l)=>{const s=i.resolveComponent("a-form-item"),o=i.resolveComponent("a-input"),r=i.resolveComponent("a-switch"),d=i.resolveComponent("a-textarea"),h=i.resolveComponent("a-form"),f=i.resolveComponent("a-tab-pane"),c=i.resolveComponent("a-tabs");return i.openBlock(),i.createElementBlock("div",Zr,[i.createVNode(c,{type:"card"},{default:i.withCtx(()=>[i.createVNode(f,{key:"pageDefine",tab:"页面设置"},{default:i.withCtx(()=>[i.createVNode(h,{model:t.value,name:"basic","label-col":{span:5},"wrapper-col":{span:16},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[t.value.sn&&t.value.sn!="new_"?(i.openBlock(),i.createBlock(s,{key:0,label:"页面编码"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(t.value.sn)+"/V"+i.toDisplayString(t.value.vers),1)]),_:1})):i.createCommentVNode("",!0),i.createVNode(s,{label:"页面标题",required:""},{default:i.withCtx(()=>[i.createVNode(o,{value:t.value.title,"onUpdate:value":l[0]||(l[0]=p=>t.value.title=p)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"页面组件",required:""},{default:i.withCtx(()=>[i.createVNode(o,{value:t.value.component,"onUpdate:value":l[1]||(l[1]=p=>t.value.component=p)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"icon图标"},{default:i.withCtx(()=>[i.createVNode(o,{value:t.value.icon,"onUpdate:value":l[2]||(l[2]=p=>t.value.icon=p)},null,8,["value"])]),_:1}),i.createVNode(s,{label:"是否全局"},{default:i.withCtx(()=>[i.createVNode(r,{checked:t.value.isGlobal,"onUpdate:checked":l[3]||(l[3]=p=>t.value.isGlobal=p),checkedValue:1,checkedChildren:"是",unCheckedChildren:"否",unCheckedValue:0},null,8,["checked"])]),_:1}),i.createVNode(s,{label:"是否模版"},{default:i.withCtx(()=>[i.createVNode(r,{checked:t.value.isTmpl,"onUpdate:checked":l[4]||(l[4]=p=>t.value.isTmpl=p),checkedValue:1,checkedChildren:"是",unCheckedChildren:"否",unCheckedValue:0},null,8,["checked"])]),_:1}),i.createVNode(s,{label:"页面备注"},{default:i.withCtx(()=>[i.createVNode(d,{value:t.value.descs,"onUpdate:value":l[5]||(l[5]=p=>t.value.descs=p),placeholder:"请输入页面备注...",rows:4},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1}),i.createVNode(f,{key:"dataDefine",tab:"数据设置"},{default:i.withCtx(()=>[i.createVNode(Jr,{editor:a.editor},null,8,["editor"])]),_:1})]),_:1})])}}}),[["__scopeId","data-v-2420ce7a"]]),Sl=ne(i.defineComponent({__name:"editor",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},pageDefine:{type:Object,required:!1}},setup(a){console.log("unione page view setup .....");const e=a,t={sn:"new_",title:"新建页面",types:"setting",vers:1,configs:{widgetList:[],dataModels:[]},component:"unione-page-view"},n=new ct,l=i.computed(()=>n.$widgetList.value||[]);i.watch(()=>e.pageDefine,o=>{o&&n.load(s.value,o)});const s=i.ref("new_");return i.onMounted(()=>{const o=i.inject("route");console.log("unione page view route",o),s.value=e.psn||o?.query?.psn||o?.meta?.psn||"new_",console.log("unione page view,psn:"+s.value),n.setModel("run"),n.load(s.value,e.pageDefine||t)}),(o,r)=>(i.openBlock(),i.createBlock(jt,{class:"unione-page-view","setting-title":"页面设置",editor:i.unref(n)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(l.value,d=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(d.render||d.widget),{key:d.wid,wid:d.wid,widget:d,editor:i.unref(n)},null,8,["wid","widget","editor"]))),128))]),_:2},[i.unref(n)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(n)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"]))}}),[["__scopeId","data-v-f792d0b4"]]),ed={class:"form-btns"},Nl=i.defineComponent({__name:"form",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},pageDefine:{type:Object,required:!1}},setup(a){const e=i.inject("router"),t=a,n={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[],dsnList:[]},component:"unione-page-view"},l=new ct,s=i.computed(()=>l.$widgetList.value||[]),o=i.computed(()=>{const c=l.define.value?.configs?.btns||[],p=c.map(m=>m.name);if(!p.includes("save")){const m={title:"保存",type:"primary",index:0,visible:!0,size:"default",name:"save"};c.splice(m.index,0,m)}if(!p.includes("submit")){const m={title:"提交",type:"primary",index:1,visible:!0,size:"default",name:"submit"};let b=m.index||1;c.splice(b,0,m)}if(!p.includes("reset")){const m={title:"重置",type:"default",index:2,visible:!0,size:"default",props:{danger:!0},name:"reset"};c.splice(m.index,0,m)}if(!p.includes("back")){const m={title:"返回",type:"default",index:3,visible:!0,size:"default",name:"back"};c.splice(m.index,0,m)}return l.model.value=="view"&&c.filter(m=>["save","submit","reset"].includes(m.name)).forEach(m=>{m.visible=!1}),c});function r({btn:c,event:p}){c.name=="save"&&d(),c.name=="reset",c.name=="back"&&h()}async function d(){const c=l.dataManager().form();let p={};for(let m in c){const b=await c[m].validate();if(l.dataManager().psn()==m){for(let y in p)b[y]=p[y];p=b}else p[m]=b}console.log("=======form data=====",p),l.dataManager().primary().save({data:p,params:l.dataManager().params}).then(m=>{console.log("save result:",m)})}function h(){e.back()}i.watch(()=>t.pageDefine,c=>{c&&l.load(f.value,c)});const f=i.ref("new_");return i.onMounted(()=>{const c=i.inject("route");console.log("unione page view route",c),f.value=t.psn||c?.query?.psn||c?.meta?.psn||"new_",console.log("unione page view,psn:"+f.value),l.setModel(c?.query?.model||c?.meta?.model||"run"),c?.query&&l.dataManager().params(c.query),l.load(f.value,t.pageDefine||n)}),(c,p)=>{const m=i.resolveComponent("unione-btn");return i.openBlock(),i.createBlock(jt,{class:"unione-page-form","setting-title":"页面设置",editor:i.unref(l)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.value,b=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(b.widget),{key:b.wid,wid:b.wid,widget:b,editor:i.unref(l)},null,8,["wid","widget","editor"]))),128)),i.createElementVNode("div",ed,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(o.value,b=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:b.name},[b.visible!=!1?(i.openBlock(),i.createBlock(m,{key:0,widget:b,editor:i.unref(l),ctx:{},onClick:r},null,8,["widget","editor"])):i.createCommentVNode("",!0)],64))),128))])]),_:2},[i.unref(l)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(l)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"])}}}),td=["onMouseover"],id={key:0,class:"node-opts"},nd={class:"form-warp"},ld={class:"form-btns"},Bl=i.defineComponent({__name:"tree",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},storage:{type:Object,required:!0},fields:{type:Array,required:!1},setting:{type:Object,required:!0},opts:{type:Object,required:!1},btns:{type:Object,required:!1},event:{type:Object,required:!1}},emits:["btnClick","treeClick"],setup(a,{emit:e}){const t=K.useDialog(),n=i.inject("router"),l=a,s={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[],dsnList:[]},component:"unione-page-tree"};function o(){if(l.fields?.length){const F={widget:"unione-form",dsn:"primary",primary:!0,widgets:l.fields};s.configs.widgets=[F]}s.configs.dsnList=["primary"],r.dataManager().use("primary","form").store(l.storage),s.configs.btns=l.btns||[],l.btns==!1&&(s.configs.btns=!1),s.configs.opts=l.opts||[],l.opts==!1&&(s.configs.opts=!1),s.configs.event=l.event||{},s.configs.setting=l.setting||{}}const r=new ct,d=i.ref(!1),h=i.ref([]),f=i.ref({}),c=i.ref(null),p=i.ref(null),m=i.ref([]),b=i.ref([]),y=i.ref(0),w=i.computed(()=>{const F={disabled:!1,draggable:!1,multiple:!1,selectable:!0,checkable:!1,showLine:!0,showIcon:!0,idField:"id",pidField:"pid",labelField:"title",leafField:"isLeaf",iconField:"iconName",...l.setting?.tree||{}};return r.define.value?.configs?.tree||F}),v=i.computed(()=>{const F=r.define.value?.configs?.opts;if(typeof F=="boolean"&&F==!1)return!1;const _=(F||[]).map($=>typeof $=="string"?{name:$,visible:!1}:$),D=[];return _.forEach($=>{D.push($.name)}),console.log("opts addBtn",_),_.filter($=>$.name=="add")[0]||{visible:!0,name:"add",icon:"PlusOutlined",title:"新建",props:{block:!0,type:"dashed"}}}),k=i.computed(()=>{const F=r.define.value?.configs?.opts;if(typeof F=="boolean"&&F==!1)return[];const _=(F||[]).map(Q=>typeof Q=="string"?{name:Q,visible:!1}:Q),D=[],$=[];return _.forEach(Q=>{$.push(Q.name),Q.name!="add"&&D.push(Q)}),$.includes("delete")||D.splice(1,0,{visible:!0,name:"delete",icon:"DeleteOutlined",tooltip:"删除",props:{type:"text"}}),$.includes("child")||D.splice(2,0,{visible:!0,name:"child",icon:"PlusOutlined",tooltip:"创建下级",props:{type:"text"}}),console.log("opts menuBtn",D),D});function O({btn:F,event:_},D){_.stopPropagation();const $=f.value[D[w.value.idField]];if(console.log("onTreeMenuClick,btn:",F),console.log("onTreeMenuClick,node:",D),console.log("onTreeMenuClick,curentNode:",$),F.name=="child"){const Q=f.value[$[w.value.idField]];Q.isLeaf=!1,c.value={},c.value[w.value.pidField]=Q[w.value.idField],c.value[w.value.labelField]="新建...",c.value[w.value.idField]="new_"+y.value,c.value.parentNode=Q,y.value=y.value+1,Q.children||(Q.children=[],b.value.push(Q[w.value.idField])),I.value.createNode&&I.value.createNode(c.value,Q,r.dataManager().params()),f.value[c.value[w.value.idField]]=c.value,Q.children.push(c.value),m.value=[c.value[w.value.idField]],r.dataManager().primary().setValue(c.value)}F.name=="delete"&&($[w.value.idField]&&($[w.value.idField]+"").startsWith("new_")?($.parentNode?$.parentNode.children=$.parentNode.children.filter(Q=>Q[w.value.idField]!=$[w.value.idField]):h.value=h.value.filter(Q=>Q[w.value.idField]!=$[w.value.idField]),delete f.value[$[w.value.idField]]):r.dataManager().primary().deleteByIds([$[w.value.idField]]).then(()=>{if($.parentNode){const Q=f.value[$[w.value.pidField]];Q.children=Q.children.filter(R=>R[w.value.idField]!=$[w.value.idField])}else h.value=h.value.filter(Q=>Q[w.value.idField]!=$[w.value.idField]);delete f.value[$[w.value.idField]]}))}function g(F,{expanded:_,node:D}){_&&(c.value=D.dataRef,r.dataManager().primary().setValue(c.value),T())}function u(F,_){_.selected?(c.value=_.node.dataRef,r.dataManager().primary().setValue(c.value)):c.value&&(m.value=[c.value[w.value.idField]]),U("treeClick",{keys:F,event:_})}const N=i.computed(()=>{if(l.storage?.orderBy){const F=l.storage.orderBy.split(" ");return[{name:F[0],asc:F[1].toLowerCase()=="asc"}]}return[]});i.watch(()=>l.params,()=>{d.value&&(h.value=[],f.value={},c.value=null,m.value=[],b.value=[],y.value=0,r.dataManager().params(l.params||{}),console.log("params changed props.params",l.params),T())}),i.watch(()=>c.value,()=>{console.log("active node changed",c.value),C(!c.value)});const V=i.ref(null);i.watch(V,()=>{V.value&&c.value&&r.dataManager().primary().setValue(c.value)});function C(F=!0){const _=r.dataManager().form();for(let D in _)_[D].setDisabled(F)}function x(){if(c.value={},c.value[w.value.pidField]=-1,c.value[w.value.labelField]="新建...",c.value[w.value.idField]="new_"+y.value,y.value=y.value+1,I.value.createNode&&I.value.createNode(c.value,null,r.dataManager().params()),c.value[w.value.pidField]==-1)h.value.push(c.value);else{const F=f.value[c.value[w.value.pidField]];F?(F.children||(F.children=[]),F.children.push(c.value)):h.value.push(c.value)}m.value=[c.value[w.value.idField]],f.value[c.value[w.value.idField]]=c.value,r.dataManager().primary().setValue(c.value)}const S=i.ref(""),M=tn(()=>{r.dataManager().primary().find({page:1,pageSize:9999,keywords:S.value,needCount:!1,body:w.value.async==!1?null:{},sorts:N.value}).then(F=>{if(f.value={},h.value=[],F.body?.length){const _={};F.body.forEach(D=>{_[D[w.value.idField]]=D}),F.body.forEach(D=>{const $=_[D[w.value.pidField]];$?($.children||($.children=[],$.isLeaf=!1),$.children.push(D)):h.value.push(D)})}})},400);function T(){const F={};if(F[w.value.pidField]=l.params[w.value.pidField]||-1,c.value){if(c.value.children?.length||w.value.async==!1)return;F[w.value.pidField]=c.value[w.value.idField],r.dataManager().primary().find({page:1,pageSize:999,body:F,sorts:N.value}).then(_=>{c.value.children=_.body||[],c.value.children.forEach(D=>{D.isLeaf=!!D[w.value.leafField],f.value[D[w.value.idField]]=D,D.parentNode=f.value[D[w.value.pidField]]})})}else{const _=w.value.async==!1?null:{page:1,pageSize:999,body:F,sorts:N.value};r.dataManager().primary().find(_).then(D=>{if(w.value.async==!1){if(h.value=[],D.body?.length){const $={};D.body.forEach(Q=>{$[Q[w.value.idField]]=Q}),D.body.forEach(Q=>{const R=$[Q[w.value.pidField]];R?(R.children||(R.children=[],R.isLeaf=!1),R.children.push(Q)):h.value.push(Q)})}}else h.value=D.body||[],h.value.forEach($=>{$.isLeaf=!!$[w.value.leafField],f.value[$[w.value.idField]]=$})})}}const E=i.computed(()=>r.$widgetList.value||[]),I=i.computed(()=>{const F={...r.define.value?.configs?.event||{}};for(const _ in F)F[_]&&typeof F[_]!="function"&&F[_].enable&&F[_].scriptText&&(_=="createNode"?F[_]=new Function("node","parent","params",F[_].scriptText):F[_]=new Function("data","event",F[_].scriptText));return F}),L=i.computed(()=>r.define.value?.configs?.setting||l.setting||{});i.provide("pageSetting",L.value);const A=i.computed(()=>{const F=r.define.value?.configs?.btns;if(typeof F=="boolean"&&F==!1)return[];const _=(r.define.value?.configs?.btns||[]).map($=>typeof $=="string"?{name:$,visible:!1}:{size:"default",...$}),D=_.map($=>$.name);if(!D.includes("save")){const $={title:"保存",type:"primary",index:0,visible:!0,size:"default",name:"save"};_.splice($.index,0,$)}if(!D.includes("reset")){const $={title:"重置",type:"default",index:1,visible:!0,size:"default",props:{danger:!0},name:"reset"};_.splice($.index,0,$)}if(!D.includes("back")){const $={title:"返回",type:"default",index:_.length,visible:!0,size:"default",name:"back"};_.splice($.index,0,$)}return r.model.value=="view"&&_.filter($=>["save","submit","reset"].includes($.name)).forEach($=>{$.visible=!1}),_}),U=e;function P({btn:F,event:_}){F.name=="save"&&G({btn:F,event:_}),F.name=="reset",F.name=="back"&&j(),U("btnClick",{btn:F,event:_})}async function G(F){const _=r.dataManager().form();let D={...c.value};for(let $ in _){const Q=await _[$].validate();if(r.dataManager().psn()==$)for(let R in Q)D[R]=Q[R];else D[$]=Q}if(D[w.value.pidField]&&(D[w.value.pidField]+"").startsWith("new_")){t.error({content:"请先保存父节点!"});return}D[w.value.idField]&&(D[w.value.idField]+"").startsWith("new_")&&delete D[w.value.idField],delete D.parentNode,delete D.children,D[w.value.leafField]=D[w.value.leafField]?1:0,I.value.preSave&&I.value.preSave(D,F),console.log("=======form data=====",D),r.dataManager().primary().save({data:D}).then($=>{console.log("save result:",$),c.value[w.value.idField]=$.body,m.value=[$.body],f.value[$.body]=c.value,c.value.children?.forEach(Q=>{Q[w.value.pidField]=$.body}),I.value.postSaved&&I.value.postSaved(D,F)})}function j(){n.back()}const B=i.ref("new_");return i.onMounted(()=>{const F=i.inject("route");console.log("unione page tree route",F),B.value=l.psn||F?.query?.psn||F?.meta?.psn||"new_",console.log("unione page tree,psn:"+B.value),r.setModel(F?.query?.model||F?.meta?.model||"run");const _={...l.params||{},...F?.query||{},...F?.params||{}};r.dataManager().params(_),o(),r.load(B.value,s),i.nextTick(()=>{C(!0)}),T(),d.value=!0}),(F,_)=>{const D=i.resolveComponent("SearchOutlined"),$=i.resolveComponent("a-input"),Q=i.resolveComponent("unione-btn"),R=i.resolveComponent("a-tree");return i.openBlock(),i.createBlock(jt,{class:"unione-page-tree","setting-title":"页面设置",editor:i.unref(r)},i.createSlots({default:i.withCtx(()=>[i.createElementVNode("div",{class:"tree-warp",onContextmenu:_[4]||(_[4]=i.withModifiers(()=>{},["prevent"]))},[i.createVNode($,{size:"small",class:"input-search",placeholder:"输入关键字搜索...",value:S.value,"onUpdate:value":_[0]||(_[0]=X=>S.value=X),onChange:i.unref(M),onPressEnter:i.unref(M)},{suffix:i.withCtx(()=>[i.createVNode(D)]),_:1},8,["value","onChange","onPressEnter"]),v.value?(i.openBlock(),i.createBlock(Q,{key:0,widget:v.value,onClick:x},null,8,["widget"])):i.createCommentVNode("",!0),i.createVNode(R,{"show-line":w.value.showLine,"show-icon":w.value.showIcon,disabled:w.value.disabled,blockNode:!0,draggable:w.value.draggable,multiple:w.value.multiple,selectable:w.value.selectable,checkable:w.value.checkable,fieldNames:{title:w.value.labelField,key:w.value.idField},selectedKeys:m.value,"onUpdate:selectedKeys":_[2]||(_[2]=X=>m.value=X),expandedKeys:b.value,"onUpdate:expandedKeys":_[3]||(_[3]=X=>b.value=X),"tree-data":h.value,onExpand:g,onSelect:u},i.createSlots({icon:i.withCtx(({dataRef:X})=>[X[w.value.iconField]?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(X[w.value.iconField]),{key:0,class:"node-icon"})):i.createCommentVNode("",!0)]),_:2},[k.value?.length?{name:"title",fn:i.withCtx(({dataRef:X})=>[i.createElementVNode("div",{class:"node-label",onMouseover:()=>p.value=X,onMouseleave:_[1]||(_[1]=()=>p.value=null)},[i.createElementVNode("span",null,i.toDisplayString(X[w.value.labelField]),1),c.value&&c.value[w.value.idField]==X[w.value.idField]||p.value&&p.value[w.value.idField]==X[w.value.idField]?(i.openBlock(),i.createElementBlock("div",id,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(k.value,Z=>(i.openBlock(),i.createElementBlock(i.Fragment,null,[!I.value.btnVisible||I.value.btnVisible(Z,X)?(i.openBlock(),i.createBlock(Q,{key:Z.name,widget:Z,ctx:{node:X},onClick:ge=>O(ge,X)},null,8,["widget","ctx","onClick"])):i.createCommentVNode("",!0)],64))),256))])):i.createCommentVNode("",!0)],40,td)]),key:"0"}:void 0]),1032,["show-line","show-icon","disabled","draggable","multiple","selectable","checkable","fieldNames","selectedKeys","expandedKeys","tree-data"])],32),i.createElementVNode("div",nd,[i.renderSlot(F.$slots,"form-warp",{class:"form-warp"},()=>[i.createElementVNode("div",{ref_key:"formWarp",ref:V},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(E.value,X=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(X.widget),{key:X.wid,wid:X.wid,widget:X,editor:i.unref(r)},null,8,["wid","widget","editor"]))),128)),i.createElementVNode("div",ld,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(A.value,X=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:X.name},[X.visible!=!1?(i.openBlock(),i.createBlock(Q,{key:0,widget:X,editor:i.unref(r),disabled:!c.value,ctx:{},onClick:P},null,8,["widget","editor","disabled"])):i.createCommentVNode("",!0)],64))),128))])],512)])])]),_:2},[i.unref(r)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(r)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"])}}}),Ol=i.defineComponent({__name:"list",props:{psn:{type:String,required:!1},params:{type:Object,default(){return{}}},storage:{type:Object,required:!0},fields:{type:Array,required:!0},queryBtns:{type:Array,required:!1},operation:{type:Object,required:!1},selection:{type:Object,required:!1},leftBtns:{type:Object,required:!1},rightBtns:{type:Object,required:!1}},emits:["btnClick"],setup(a,{expose:e,emit:t}){const n=a,l=i.ref(null),s={sn:"new_",title:"新建页面",types:"code",vers:1,configs:{widgets:[{widget:"unione-query",dsn:"",primary:!0,fields:[]},{widget:"unione-table",dsn:"",columns:[]}],dsnList:[]},component:"unione-page-list"};function o(){if(n.fields?.length){s.configs.widgets[0].dsn="primary",s.configs.widgets[0].fields=n.fields.filter(O=>O.isQuery),s.configs.widgets[0].btns=n.queryBtns||[],s.configs.widgets[0].params=n.params||{},s.configs.dsnList=["primary"],s.configs.widgets[1].dsn="primary";const k=n.fields.filter(O=>O.isPk)[0];k&&k.name&&(s.configs.widgets[1].dataKey=k.name),s.configs.widgets[1].columns=n.fields.filter(O=>O.hidden!=!0),s.configs.widgets[1].operation=K.utils.obj.ext(s.configs.widgets[1].operation,n.operation||{}),n.operation==!1&&(s.configs.widgets[1].operation=!1),n.selection==!1&&(s.configs.widgets[1].selection=!1),s.configs.widgets[1].leftBtns=n.leftBtns==!1?!1:n.leftBtns||[],s.configs.widgets[1].rightBtns=n.rightBtns==!1?!1:n.rightBtns||[],r.dataManager().use("primary","list").store(n.storage)}}const r=new ct,d=i.computed(()=>r.$widgetList.value||[]),h=t;function f(k){h("btnClick",k)}const c=i.ref("new_");i.onMounted(()=>{const k=i.inject("route");console.log("unione page view route",k),c.value=n.psn||k?.query?.psn||k?.meta?.psn||"new_",console.log("unione page view,psn:"+c.value),r.setModel(k?.query?.model||k?.meta?.model||"run");const O={...n.params||{},...k?.query||{},...k?.params||{}};r.dataManager().params(O),o(),r.load(c.value,s)});function p(){return r.dataManager().use("primary","list")}function m(k){k?r.ebus.$emit("table-list-search",k):r.ebus.$emit("table-list-reload")}function b(k){r.dataManager().params(k),r.ebus.$emit("query-form-params",k),r.ebus.$emit("table-list-search",{params:k})}function y(){return l.value?l.value[0]:null}function w(){return l.value?l.value[0].getSelected():null}function v(){l.value&&l.value[0].clearSelected()}return e({storage:p,editor:r,reload:m,setParams:b,getTable:y,getSelected:w,clearSelected:v}),(k,O)=>(i.openBlock(),i.createBlock(jt,{class:"unione-page-list","setting-title":"页面设置",editor:i.unref(r)},i.createSlots({default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(d.value,g=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:g.wid},[g.widget=="unione-table"?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(g.widget),{key:0,wid:g.wid,widget:g,editor:i.unref(r),onBtnClick:f,ref_for:!0,ref_key:"table",ref:l},null,40,["wid","widget","editor"])):(i.openBlock(),i.createBlock(i.resolveDynamicComponent(g.widget),{key:1,wid:g.wid,widget:g,editor:i.unref(r),onBtnClick:f},null,40,["wid","widget","editor"]))],64))),128))]),_:2},[i.unref(r)?{name:"page-setting",fn:i.withCtx(()=>[i.createVNode(zt,{editor:i.unref(r)},null,8,["editor"])]),key:"0"}:void 0]),1032,["editor"]))}}),ft={release(a){return K.axios.admin({url:"/api/data/define/release",method:"post",data:a})},find(a){return K.axios.admin({url:"/api/data/define/find",method:"post",data:a})},save(a){return K.axios.admin({url:"/api/data/define/save",method:"post",data:a})},delete(a){return K.axios.admin({url:"/api/data/define/delete",method:"post",data:a})},detail(a){return K.axios.admin({url:"/api/data/define/detail",method:"post",headers:{"Content-Type":"application/json"},data:a})},loadFromDb(a){return K.axios.admin({url:"/api/data/define/load/from/db",method:"post",headers:{"Content-Type":"multipart/form-data"},data:a})},impFromDb(a){return K.axios.admin({url:"/api/data/define/imp/from/db",method:"post",headers:{"Content-Type":"multipart/form-data"},data:a})}},sd={class:"unione-page list-page"},od=ne(i.defineComponent({__name:"list",setup(a){const e=Ie(),t=K.useDialog(),n=i.inject("router"),l=i.ref({fields:[{title:"标题",name:"title"},{title:"名称",name:"name"},{title:"状态",name:"status"},{title:"类别",name:"category"}]}),s=i.ref({leftBtns:[{visible:!1,name:"delBatch"},{title:"从数据库导入",icon:"FunnelPlotOutlined",name:"impFromDb",props:{danger:!0,ghost:!0}},{title:"代码生成",icon:"CodeOutlined",name:"genCode"}],rightBtns:[{visible:!1,name:"downTmpl"}],columns:[{title:"类别",name:"category"},{title:"标题",name:"title"},{title:"名称",name:"name"},{title:"编码",name:"sn"},{title:"版本",name:"vers"},{title:"发布时间",name:"publishDate"},{title:"创建时间",name:"created"},{title:"状态",name:"status"}],operation:{title:"操作",width:190,btns:[{title:"预览",name:"view"},{title:"版本发布",name:"release",props:{danger:!0}},{title:"版本管理",name:"vers"},{title:"配置管理",name:"configs"},{title:"权限管理",name:"permis"},{title:"权限分配",name:"auth"},{title:"复制",name:"copy"}],count:2,more:{layout:"vertical"}}});i.onMounted(()=>{r()});const o=i.ref({pagination:{total:0,current:1,pageSize:20},loading:!1,params:{},data:[]});function r(){o.value.loading=!0,ft.find({page:o.value.pagination.current,pageSize:o.value.pagination.pageSize,body:o.value.params,keywords:o.value.keywords}).then(g=>{o.value.data=g.body,o.value.pagination.total=g.total*1}).finally(()=>{o.value.loading=!1})}function d(g){o.value.pagination.current=g.pagination.current,o.value.pagination.pageSize=g.pagination.pageSize,r()}function h({params:g,keywords:u}){o.value.pagination.current=1,o.value.params=g,o.value.keywords=u,r()}function f({btn:g,event:u,row:N}){console.log("table btn click",g,u,N),(g.name=="add"||g.name=="edit")&&n.push({path:"/dev/data/define/edit",query:N?{id:N.id}:{}}),g.name=="impFromDb"&&(p.value=!0),g.name=="release"&&c(N),g.name=="view"&&n.push({path:e.listPageUrl,query:{psn:N.sn+":list",model:"preview"}})}function c(g){t.confirm({content:"确定要发布当前数据么?",onOk:()=>{ft.release([g.id]).then(u=>{u.success?(t.success({title:"发布成功",content:u.body}),r()):t.error({title:"发布失败",content:u.body})})}})}const p=i.ref(!1),m=i.ref({keywords:{visible:!1},fields:[{title:"数据源",name:"dsId",value:1,visible:!0,widget:"unione-select-box",convert:{types:"local",url:"/api/data/source/find",search:!0}},{title:"名称",name:"tableName",visible:!0}],btns:[{visible:!1,name:"reset"},{name:"advanced",visible:!1},{name:"imp",title:"提交",props:{danger:!0}}]}),b=i.ref({leftBtns:!1,rightBtns:!1,columns:[{title:"名称",name:"name"},{title:"标题",name:"title"}],operation:!1}),y=i.ref({pagination:{total:0,current:1,pageSize:10},loading:!1,params:{},data:[]});function w(g){!g||!Object.keys(g).length||!g.dsId||(J.message.loading("数据加载中..."),y.value.params=g,y.value.loading=!0,ft.loadFromDb(g).then(u=>{y.value.loading=!1,J.message.destroy(),u.success?(u.body.forEach(N=>{N.checkable=!!N.id}),y.value.data=u.body,y.value.pagination.total=u.body.length):J.message.error(u.message)}))}function v(g){y.value.pagination.current=g.pagination.current,y.value.pagination.pageSize=g.pagination.pageSize}const k=i.ref();function O({btn:g}){if(g.name!="imp")return;const u=k.value.getSelected();u?.keys?.length?t.confirm({content:"确定导入选中的"+u.keys.length+"条记录么?",onOk:()=>{J.message.loading("数据导入中..."),ft.impFromDb({dsId:y.value.params.dsId,tables:u.keys.join()}).then(N=>{J.message.destroy(),N.success?(t.success({content:N.message}),o.value.pagination.current=1,r()):t.error({context:N.message})})}}):t.error({content:"请选择目标记录!"})}return(g,u)=>{const N=i.resolveComponent("UnioneQuery"),V=i.resolveComponent("UnioneTable"),C=i.resolveComponent("a-drawer");return i.openBlock(),i.createElementBlock("div",sd,[i.createVNode(N,{widget:l.value,onQuery:h,onReset:h},null,8,["widget"]),i.createVNode(V,{widget:s.value,dataList:o.value.data,loading:o.value.loading,pagination:o.value.pagination,onChange:d,onBtnClick:f},null,8,["widget","dataList","loading","pagination"]),i.createVNode(C,{title:"从数据库中导入",width:550,visible:p.value,"onUpdate:visible":u[0]||(u[0]=x=>p.value=x),placement:"left"},{default:i.withCtx(()=>[i.createVNode(N,{widget:m.value,onQuery:w,onReset:w,onBtnClick:O,class:"load-table-form"},null,8,["widget"]),i.createVNode(V,{widget:b.value,dataList:y.value.data,loading:y.value.loading,pagination:y.value.pagination,onChange:v,rowKey:"name",ref_key:"loadTableObj",ref:k},null,8,["widget","dataList","loading","pagination"])]),_:1},8,["visible"])])}}}),[["__scopeId","data-v-165bc175"]]),ad={class:"unione-props-setting data-field-manage"},rd={key:0},dd={key:1},cd=["onClick"],hd=["onClick"],fd=["onClick"],ud={key:1},pd=ne(i.defineComponent({__name:"dataFieldMange",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:m})=>m+1},{title:"名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"标题",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"数据类型",dataIndex:"dataType",key:"dataType",width:"80px",align:"center"},{title:"长度",dataIndex:"dataLen",key:"dataLen",width:"60px",align:"center"},{title:"小数点",dataIndex:"dataPrec",key:"dataPrec",width:"60px",align:"center"},{title:"默认值",dataIndex:"dataValue",key:"dataValue",width:"60px",align:"center"},{title:"主键",dataIndex:"isPk",key:"isPk",width:"40px",align:"center"},{title:"外键",dataIndex:"isFk",key:"isFk",width:"30px",align:"center"},{title:"非空",dataIndex:"isNull",key:"isNull",width:"30px",align:"center"},{title:"同步",dataIndex:"syncEnable",key:"syncEnable",width:"30px",align:"center"},{title:"备注",dataIndex:"descs",key:"descs",width:"140px",align:"center"}]),t=i.useModel(a,"modelValue"),n=i.ref({selectedRowKeys:[],columnWidth:"25px",onChange:m=>{m.forEach(b=>{n.value.selectedRowKeys.includes(b)||n.value.selectedRowKeys.push(b);const y=[];t.value.forEach(w=>{!m.includes(w.name)&&n.value.selectedRowKeys.includes(w.name)&&y.push(w.name)}),y.length&&(n.value.selectedRowKeys=n.value.selectedRowKeys.filter(w=>!y.includes(w)))})}}),l={mounted:m=>m.focus()},s=i.ref({});function o(){const m=Object.keys(s.value);if(m.length)for(let b in m){const y=t.value.filter(w=>w.name==b);if(y&&y[0]){let w=s.value[b];Object.keys(w).forEach(v=>{y[0][v]=w[v]})}}s.value={}}function r(m,b){o();const y={};y[b]=m[b]||"",s.value[m.name]=y}function d(m,b){if(!m||!b){s.value={};return}const y=s.value[m.name][b];if(b=="name"&&t.value.filter(v=>v[b]==y&&v.name!=m.name).length>0){J.Modal.warn({title:"提示信息",content:"字段名称["+y+"]已存在"});return}m[b]=y,s.value={}}function h(m,b){const y=t.value.filter(w=>w.name==m.name)[0];return b=="isFk"?y.configs?.fkey?.enable:y[b]==1}function f(m,b){const y=t.value.filter(w=>w.name==m.name)[0];b=="isFk"?(y.configs||(y.configs={}),y.configs.fkey||(y.configs.fkey={}),y.configs.fkey.enable=!y.configs.fkey.enable):y[b]!=1?y[b]=1:y[b]=0}function c(){if(o(),t.value.filter(y=>y.name=="new_").length>0){s.value.new_={name:"new_"};return}const b={title:"",name:"new_",dataType:"String",isPk:0};t.value.push(b),s.value[b.name]={name:"new_"}}function p(){if(!n.value.selectedRowKeys.length){J.Modal.info({title:"提示信息",content:"请选择要删除的字段!"});return}J.Modal.confirm({title:"确认信息",content:"确定要删除选中的["+n.value.selectedRowKeys.length+"]字段么?",onOk:()=>{t.value=t.value.filter(m=>!n.value.selectedRowKeys.includes(m.name)),n.value.selectedRowKeys=[]}})}return(m,b)=>{const y=i.resolveComponent("a-button"),w=i.resolveComponent("a-tooltip"),v=i.resolveComponent("a-input"),k=i.resolveComponent("a-input-number"),O=i.resolveComponent("a-select-option"),g=i.resolveComponent("a-select"),u=i.resolveComponent("a-checkbox"),N=i.resolveComponent("a-table");return i.openBlock(),i.createElementBlock("div",ad,[i.createVNode(y,{class:"btn btn-add",type:"primary",onClick:c,size:"small"},{default:i.withCtx(()=>b[1]||(b[1]=[i.createTextVNode("新增")])),_:1}),i.createVNode(y,{class:"btn btn-delete",type:"primary",danger:"",onClick:p,size:"small"},{default:i.withCtx(()=>b[2]||(b[2]=[i.createTextVNode(" 删除 ")])),_:1}),i.createVNode(N,{columns:e.value,"data-source":t.value,pagination:!0,bordered:"","row-selection":n.value,scroll:{x:1150},"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:V})=>[["name","title"].includes(V.key)?(i.openBlock(),i.createElementBlock("span",rd,[b[3]||(b[3]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(V.title),1)])):i.createCommentVNode("",!0),["descs","dataLen","dataPrec","dataValue","dataType"].includes(V.key)?(i.openBlock(),i.createElementBlock("span",dd,[i.createVNode(i.unref(He.FormOutlined)),i.createTextVNode(" "+i.toDisplayString(V.title),1)])):i.createCommentVNode("",!0),V.key==="isPk"?(i.openBlock(),i.createBlock(w,{key:2,title:"至少配置一个主键字段"},{default:i.withCtx(()=>[b[4]||(b[4]=i.createElementVNode("span",{style:{color:"red","margin-right":"3px","font-size":"16px"}},"*",-1)),i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="isFk"?(i.openBlock(),i.createBlock(w,{key:3,title:"是否是外键字段"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="isNull"?(i.openBlock(),i.createBlock(w,{key:4,title:"是否允许为空"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0),V.key==="syncEnable"?(i.openBlock(),i.createBlock(w,{key:5,title:"是否同步到数据库"},{default:i.withCtx(()=>[i.createTextVNode(i.toDisplayString(V.title),1)]),_:2},1024)):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:V,text:C,record:x})=>[["name","title","descs","dataValue"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(v,{key:0,value:s.value[x.name][V.dataIndex],"onUpdate:value":S=>s.value[x.name][V.dataIndex]=S,onBlur:S=>d(x,V.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(C||" "),1)],64))],10,cd)):i.createCommentVNode("",!0),["dataLen","dataPrec"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(k,{key:0,value:s.value[x.name][V.dataIndex],"onUpdate:value":S=>s.value[x.name][V.dataIndex]=S,onBlur:S=>d(x,V.dataIndex),style:{margin:"-5px 0"}},null,8,["value","onUpdate:value","onBlur"])),[[l]]):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(C||" "),1)],64))],10,hd)):["dataType"].includes(V.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[x.name]||!Object.keys(s.value[x.name]).includes(V.dataIndex))&&!C&&"empty"]),onClick:S=>r(x,V.dataIndex)},[s.value[x.name]&&Object.keys(s.value[x.name]).includes(V.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(g,{key:0,value:x[V.dataIndex],"onUpdate:value":S=>x[V.dataIndex]=S,onBlur:b[0]||(b[0]=S=>d())},{default:i.withCtx(()=>[i.createVNode(O,{key:"String",value:"String"}),i.createVNode(O,{key:"Long",value:"Long"}),i.createVNode(O,{key:"Short",value:"Short"}),i.createVNode(O,{key:"Integer",value:"Integer"}),i.createVNode(O,{key:"Float",value:"Float"}),i.createVNode(O,{key:"Double",value:"Double"}),i.createVNode(O,{key:"Date",value:"Date"}),i.createVNode(O,{key:"Timestamp",value:"Timestamp"})]),_:2},1032,["value","onUpdate:value"])),[[l]]):(i.openBlock(),i.createElementBlock("span",ud,i.toDisplayString(C),1))],10,fd)):["syncEnable","isFk","isPk"].includes(V.dataIndex)?(i.openBlock(),i.createBlock(u,{key:3,checked:h(x,V.dataIndex),onClick:S=>f(x,V.dataIndex)},null,8,["checked","onClick"])):["isNull"].includes(V.dataIndex)?(i.openBlock(),i.createBlock(u,{key:4,checked:!h(x,V.dataIndex),onClick:S=>f(x,V.dataIndex)},null,8,["checked","onClick"])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source","row-selection"])])}}}),[["__scopeId","data-v-4020e3f0"]]),Vl=1024;let md=0,ln=class{constructor(e,t){this.from=e,this.to=t}};class te{constructor(e={}){this.id=md++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ne.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}te.closedBy=new te({deserialize:a=>a.split(" ")}),te.openedBy=new te({deserialize:a=>a.split(" ")}),te.group=new te({deserialize:a=>a.split(" ")}),te.isolate=new te({deserialize:a=>{if(a&&a!="rtl"&&a!="ltr"&&a!="auto")throw new RangeError("Invalid value for isolate: "+a);return a||"auto"}}),te.contextHash=new te({perNode:!0}),te.lookAhead=new te({perNode:!0}),te.mounted=new te({perNode:!0});class hi{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[te.mounted.id]}}const gd=Object.create(null);class Ne{constructor(e,t,n,l=0){this.name=e,this.props=t,this.id=n,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):gd,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new Ne(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(l)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return l}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let l of n.split(" "))t[l]=e[n];return n=>{for(let l=n.prop(te.group),s=-1;s<(l?l.length:0);s++){let o=t[s<0?n.name:l[s]];if(o)return o}}}}Ne.none=new Ne("",Object.create(null),0,8);class sn{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let l=null;for(let s of e){let o=s(n);o&&(l||(l=Object.assign({},n.props)),l[o[0].id]=o[1])}t.push(l?new Ne(n.name,l,n.id,n.flags):n)}return new sn(t)}}const fi=new WeakMap,_l=new WeakMap;var pe;(function(a){a[a.ExcludeBuffers=1]="ExcludeBuffers",a[a.IncludeAnonymous=2]="IncludeAnonymous",a[a.IgnoreMounts=4]="IgnoreMounts",a[a.IgnoreOverlays=8]="IgnoreOverlays"})(pe||(pe={}));class he{constructor(e,t,n,l,s){if(this.type=e,this.children=t,this.positions=n,this.length=l,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,r]of s)this.props[typeof o=="number"?o:o.id]=r}}toString(){let e=hi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let l=n.toString();l&&(t&&(t+=","),t+=l)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new rn(this.topNode,e)}cursorAt(e,t=0,n=0){let l=fi.get(this)||this.topNode,s=new rn(l);return s.moveTo(e,t),fi.set(this,s._tree),s}get topNode(){return new Me(this,0,0,null)}resolve(e,t=0){let n=qt(fi.get(this)||this.topNode,e,t,!1);return fi.set(this,n),n}resolveInner(e,t=0){let n=qt(_l.get(this)||this.topNode,e,t,!0);return _l.set(this,n),n}resolveStack(e,t=0){return yd(this,e,t)}iterate(e){let{enter:t,leave:n,from:l=0,to:s=this.length}=e,o=e.mode||0,r=(o&pe.IncludeAnonymous)>0;for(let d=this.cursor(o|pe.IncludeAnonymous);;){let h=!1;if(d.from<=s&&d.to>=l&&(!r&&d.type.isAnonymous||t(d)!==!1)){if(d.firstChild())continue;h=!0}for(;h&&n&&(r||!d.type.isAnonymous)&&n(d),!d.nextSibling();){if(!d.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:cn(Ne.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,l)=>new he(this.type,t,n,l,this.propValues),e.makeTree||((t,n,l)=>new he(Ne.none,t,n,l)))}static build(e){return wd(e)}}he.empty=new he(Ne.none,[],[],0);class on{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new on(this.buffer,this.index)}}class tt{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ne.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],l=this.set.types[t],s=l.name;if(/\W/.test(s)&&!l.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,l,s){let{buffer:o}=this,r=-1;for(let d=e;d!=t&&!(Ml(s,l,o[d+1],o[d+2])&&(r=d,n>0));d=o[d+3]);return r}slice(e,t,n){let l=this.buffer,s=new Uint16Array(t-e),o=0;for(let r=e,d=0;r<t;){s[d++]=l[r++],s[d++]=l[r++]-n;let h=s[d++]=l[r++]-n;s[d++]=l[r++]-e,o=Math.max(o,h)}return new tt(s,o,this.set)}}function Ml(a,e,t,n){switch(a){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function qt(a,e,t,n){for(var l;a.from==a.to||(t<1?a.from>=e:a.from>e)||(t>-1?a.to<=e:a.to<e);){let o=!n&&a instanceof Me&&a.index<0?null:a.parent;if(!o)return a;a=o}let s=n?0:pe.IgnoreOverlays;if(n)for(let o=a,r=o.parent;r;o=r,r=o.parent)o instanceof Me&&o.index<0&&((l=r.enter(e,t,s))===null||l===void 0?void 0:l.from)!=o.from&&(a=r);for(;;){let o=a.enter(e,t,s);if(!o)return a;a=o}}class Tl{cursor(e=0){return new rn(this,e)}getChild(e,t=null,n=null){let l=Al(this,e,t,n);return l.length?l[0]:null}getChildren(e,t=null,n=null){return Al(this,e,t,n)}resolve(e,t=0){return qt(this,e,t,!1)}resolveInner(e,t=0){return qt(this,e,t,!0)}matchContext(e){return an(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let l=t.lastChild;if(!l||l.to!=t.to)break;l.type.isError&&l.from==l.to?(n=t,t=l.prevSibling):t=l}return n}get node(){return this}get next(){return this.parent}}class Me extends Tl{constructor(e,t,n,l){super(),this._tree=e,this.from=t,this.index=n,this._parent=l}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,l,s=0){for(let o=this;;){for(let{children:r,positions:d}=o._tree,h=t>0?r.length:-1;e!=h;e+=t){let f=r[e],c=d[e]+o.from;if(Ml(l,n,c,c+f.length)){if(f instanceof tt){if(s&pe.ExcludeBuffers)continue;let p=f.findChild(0,f.buffer.length,t,n-c,l);if(p>-1)return new it(new kd(o,f,e,c),null,p)}else if(s&pe.IncludeAnonymous||!f.type.isAnonymous||dn(f)){let p;if(!(s&pe.IgnoreMounts)&&(p=hi.get(f))&&!p.overlay)return new Me(p.tree,c,e,o);let m=new Me(f,c,e,o);return s&pe.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?f.children.length-1:0,t,n,l)}}}if(s&pe.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let l;if(!(n&pe.IgnoreOverlays)&&(l=hi.get(this._tree))&&l.overlay){let s=e-this.from;for(let{from:o,to:r}of l.overlay)if((t>0?o<=s:o<s)&&(t<0?r>=s:r>s))return new Me(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Al(a,e,t,n){let l=a.cursor(),s=[];if(!l.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=l.type.is(t),!l.nextSibling())return s}for(;;){if(n!=null&&l.type.is(n))return s;if(l.type.is(e)&&s.push(l.node),!l.nextSibling())return n==null?s:[]}}function an(a,e,t=e.length-1){for(let n=a.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class kd{constructor(e,t,n,l){this.parent=e,this.buffer=t,this.index=n,this.start=l}}class it extends Tl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:l}=this.context,s=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new it(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&pe.ExcludeBuffers)return null;let{buffer:l}=this.context,s=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new it(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new it(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new it(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,l=this.index+4,s=n.buffer[this.index+3];if(s>l){let o=n.buffer[this.index+1];e.push(n.slice(l,s,o)),t.push(0)}return new he(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function El(a){if(!a.length)return null;let e=0,t=a[0];for(let s=1;s<a.length;s++){let o=a[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof Me&&t.index<0?null:t.parent,l=a.slice();return n?l[e]=n:l.splice(e,1),new bd(l,t)}class bd{constructor(e,t){this.heads=e,this.node=t}get next(){return El(this.heads)}}function yd(a,e,t){let n=a.resolveInner(e,t),l=null;for(let s=n instanceof Me?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(l||(l=[n])).push(o.resolve(e,t)),s=o}else{let o=hi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let r=new Me(o.tree,o.overlay[0].from+s.from,-1,s);(l||(l=[n])).push(qt(r,e,t,!1))}}return l?El(l):n}class rn{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Me)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=n+l.buffer[e+1],this.to=n+l.buffer[e+2],!0}yield(e){return e?e instanceof Me?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:l}=this.buffer,s=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&pe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&pe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&pe.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let l=n<0?0:this.stack[n]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(l)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:l}=this;if(l){if(e>0){if(this.index<l.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(l.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=l)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let r=n._tree.children[s];if(this.mode&pe.IncludeAnonymous||r instanceof tt||!r.type.isAnonymous||dn(r))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let l=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==l){if(l==this.index)return o;t=o,n=s+1;break e}l=this.stack[--s]}for(let l=n;l<this.stack.length;l++)t=new it(this.buffer,t,this.stack[l]);return this.bufferNode=new it(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let l=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(l=!0)}for(;l&&t&&t(this),l=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,l=!0}}}matchContext(e){if(!this.buffer)return an(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let l=e.length-1,s=this.stack.length-1;l>=0;s--){if(s<0)return an(this.node,e,l);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[l]&&e[l]!=o.name)return!1;l--}}return!0}}function dn(a){return a.children.some(e=>e instanceof tt||!e.type.isAnonymous||dn(e))}function wd(a){var e;let{buffer:t,nodeSet:n,maxBufferLength:l=Vl,reused:s=[],minRepeatType:o=n.types.length}=a,r=Array.isArray(t)?new on(t,t.length):t,d=n.types,h=0,f=0;function c(u,N,V,C,x,S){let{id:M,start:T,end:E,size:I}=r,L=f;for(;I<0;)if(r.next(),I==-1){let j=s[M];V.push(j),C.push(T-u);return}else if(I==-3){h=M;return}else if(I==-4){f=M;return}else throw new RangeError(`Unrecognized record size: ${I}`);let A=d[M],U,P,G=T-u;if(E-T<=l&&(P=w(r.pos-N,x))){let j=new Uint16Array(P.size-P.skip),B=r.pos-P.size,F=j.length;for(;r.pos>B;)F=v(P.start,j,F);U=new tt(j,E-P.start,n),G=P.start-u}else{let j=r.pos-I;r.next();let B=[],F=[],_=M>=o?M:-1,D=0,$=E;for(;r.pos>j;)_>=0&&r.id==_&&r.size>=0?(r.end<=$-l&&(b(B,F,T,D,r.end,$,_,L),D=B.length,$=r.end),r.next()):S>2500?p(T,j,B,F):c(T,j,B,F,_,S+1);if(_>=0&&D>0&&D<B.length&&b(B,F,T,D,T,$,_,L),B.reverse(),F.reverse(),_>-1&&D>0){let Q=m(A);U=cn(A,B,F,0,B.length,0,E-T,Q,Q)}else U=y(A,B,F,E-T,L-E)}V.push(U),C.push(G)}function p(u,N,V,C){let x=[],S=0,M=-1;for(;r.pos>N;){let{id:T,start:E,end:I,size:L}=r;if(L>4)r.next();else{if(M>-1&&E<M)break;M<0&&(M=I-l),x.push(T,E,I),S++,r.next()}}if(S){let T=new Uint16Array(S*4),E=x[x.length-2];for(let I=x.length-3,L=0;I>=0;I-=3)T[L++]=x[I],T[L++]=x[I+1]-E,T[L++]=x[I+2]-E,T[L++]=L;V.push(new tt(T,x[2]-E,n)),C.push(E-u)}}function m(u){return(N,V,C)=>{let x=0,S=N.length-1,M,T;if(S>=0&&(M=N[S])instanceof he){if(!S&&M.type==u&&M.length==C)return M;(T=M.prop(te.lookAhead))&&(x=V[S]+M.length+T)}return y(u,N,V,C,x)}}function b(u,N,V,C,x,S,M,T){let E=[],I=[];for(;u.length>C;)E.push(u.pop()),I.push(N.pop()+V-x);u.push(y(n.types[M],E,I,S-x,T-S)),N.push(x-V)}function y(u,N,V,C,x=0,S){if(h){let M=[te.contextHash,h];S=S?[M].concat(S):[M]}if(x>25){let M=[te.lookAhead,x];S=S?[M].concat(S):[M]}return new he(u,N,V,C,S)}function w(u,N){let V=r.fork(),C=0,x=0,S=0,M=V.end-l,T={size:0,start:0,skip:0};e:for(let E=V.pos-u;V.pos>E;){let I=V.size;if(V.id==N&&I>=0){T.size=C,T.start=x,T.skip=S,S+=4,C+=4,V.next();continue}let L=V.pos-I;if(I<0||L<E||V.start<M)break;let A=V.id>=o?4:0,U=V.start;for(V.next();V.pos>L;){if(V.size<0)if(V.size==-3)A+=4;else break e;else V.id>=o&&(A+=4);V.next()}x=U,C+=I,S+=A}return(N<0||C==u)&&(T.size=C,T.start=x,T.skip=S),T.size>4?T:void 0}function v(u,N,V){let{id:C,start:x,end:S,size:M}=r;if(r.next(),M>=0&&C<o){let T=V;if(M>4){let E=r.pos-(M-4);for(;r.pos>E;)V=v(u,N,V)}N[--V]=T,N[--V]=S-u,N[--V]=x-u,N[--V]=C}else M==-3?h=C:M==-4&&(f=C);return V}let k=[],O=[];for(;r.pos>0;)c(a.start||0,a.bufferStart||0,k,O,-1,0);let g=(e=a.length)!==null&&e!==void 0?e:k.length?O[0]+k[0].length:0;return new he(d[a.topID],k.reverse(),O.reverse(),g)}const Il=new WeakMap;function ui(a,e){if(!a.isAnonymous||e instanceof tt||e.type!=a)return 1;let t=Il.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=a||!(n instanceof he)){t=1;break}t+=ui(a,n)}Il.set(e,t)}return t}function cn(a,e,t,n,l,s,o,r,d){let h=0;for(let b=n;b<l;b++)h+=ui(a,e[b]);let f=Math.ceil(h*1.5/8),c=[],p=[];function m(b,y,w,v,k){for(let O=w;O<v;){let g=O,u=y[O],N=ui(a,b[O]);for(O++;O<v;O++){let V=ui(a,b[O]);if(N+V>=f)break;N+=V}if(O==g+1){if(N>f){let V=b[g];m(V.children,V.positions,0,V.children.length,y[g]+k);continue}c.push(b[g])}else{let V=y[O-1]+b[O-1].length-u;c.push(cn(a,b,y,g,O,u,V,null,d))}p.push(u+k-s)}}return m(e,t,n,l,0),(r||d)(c,p,o)}class ut{constructor(e,t,n,l,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=l,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let l=[new ut(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&l.push(s);return l}static applyChanges(e,t,n=128){if(!t.length)return e;let l=[],s=1,o=e.length?e[0]:null;for(let r=0,d=0,h=0;;r++){let f=r<t.length?t[r]:null,c=f?f.fromA:1e9;if(c-d>=n)for(;o&&o.from<c;){let p=o;if(d>=p.from||c<=p.to||h){let m=Math.max(p.from,d)-h,b=Math.min(p.to,c)-h;p=m>=b?null:new ut(m,b,p.tree,p.offset+h,r>0,!!f)}if(p&&l.push(p),o.to>c)break;o=s<e.length?e[s++]:null}if(!f)break;d=f.toA,h=f.toA-f.toB}return l}}class Dl{startParse(e,t,n){return typeof e=="string"&&(e=new xd(e)),n=n?n.length?n.map(l=>new ln(l.from,l.to)):[new ln(0,0)]:[new ln(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let l=this.startParse(e,t,n);for(;;){let s=l.advance();if(s)return s}}}class xd{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new te({perNode:!0});class pi{constructor(e,t,n,l,s,o,r,d,h,f=0,c){this.p=e,this.stack=t,this.state=n,this.reducePos=l,this.pos=s,this.score=o,this.buffer=r,this.bufferBase=d,this.curContext=h,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let l=e.parser.context;return new pi(e,[],t,n,n,0,[],0,l?new Pl(l,l.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,l=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let r=s.dynamicPrecedence(l);if(r&&(this.score+=r),n==0){this.pushState(s.getGoto(this.state,l,!0),this.reducePos),l<s.minRepeatTerm&&this.storeNode(l,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(l,this.reducePos);return}let d=this.stack.length-(n-1)*3-(e&262144?6:0),h=d?this.stack[d-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let c=d?this.stack[d-1]:0,p=this.bufferBase+this.buffer.length-c;if(l<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(l,h,m,p+4,!0)}if(e&262144)this.state=this.stack[d];else{let m=this.stack[d-3];this.state=s.getGoto(m,l,!0)}for(;this.stack.length>d;)this.stack.pop();this.reduceContext(l,h)}storeNode(e,t,n,l=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,r=this.buffer.length;if(r==0&&o.parent&&(r=o.bufferBase-o.parent.bufferBase,o=o.parent),r>0&&o.buffer[r-4]==0&&o.buffer[r-1]>-1){if(t==n)return;if(o.buffer[r-2]>=t){o.buffer[r-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,l);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let r=!1;for(let d=o;d>0&&this.buffer[d-2]>n;d-=4)if(this.buffer[d-1]>=0){r=!0;break}if(r)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,l>4&&(l-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=l}}shift(e,t,n,l){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=l,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,l,4);else{let s=e,{parser:o}=this.p;(l>this.pos||t<=o.maxNode)&&(this.pos=l,o.stateFlag(s,1)||(this.reducePos=l)),this.pushState(s,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,l,4)}}apply(e,t,n,l){e&65536?this.reduce(e):this.shift(e,t,n,l)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let l=this.pos;this.reducePos=this.pos=l+e.length,this.pushState(t,l),this.buffer.push(n,l,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new pi(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new vd(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let l=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&l.push(t[s],o);if(this.stack.length<120)for(let s=0;l.length<8&&s<t.length;s+=2){let o=t[s+1];l.some((r,d)=>d&1&&r==o)||l.push(t[s],o)}t=l}let n=[];for(let l=0;l<t.length&&n.length<4;l+=2){let s=t[l+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[l],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,l=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],l,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(l,s)=>{if(!t.includes(l))return t.push(l),e.allActions(l,o=>{if(!(o&393216))if(o&65536){let r=(o>>19)-s;if(r>1){let d=o&65535,h=this.stack.length-r*3;if(h>=0&&e.getGoto(this.stack[h],d,!1)>=0)return r<<19|65536|d}}else{let r=n(o,s+1);if(r!=null)return r}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Pl(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Pl{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class vd{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class mi{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new mi(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new mi(this.stack,this.pos,this.index)}}function gi(a,e=Uint16Array){if(typeof a!="string")return a;let t=null;for(let n=0,l=0;n<a.length;){let s=0;for(;;){let o=a.charCodeAt(n++),r=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let d=o-32;if(d>=46&&(d-=46,r=!0),s+=d,r)break;s*=46}t?t[l++]=s:t=new e(s)}return t}class ki{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Fl=new ki;class Cd{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Fl,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,l=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!l)return null;let o=this.ranges[--l];s-=n.from-o.to,n=o}for(;t<0?s>n.to:s>=n.to;){if(l==this.ranges.length-1)return null;let o=this.ranges[++l];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,l;if(t>=0&&t<this.chunk.length)n=this.pos+e,l=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)l=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,r=this.range;for(;r.to<=n;)r=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-n)),l=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),l}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Fl,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(n+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return n}}class vt{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Sd(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}vt.prototype.contextual=vt.prototype.fallback=vt.prototype.extend=!1,vt.prototype.fallback=vt.prototype.extend=!1;function Sd(a,e,t,n,l,s){let o=0,r=1<<n,{dialect:d}=t.p.parser;e:for(;r&a[o];){let h=a[o+1];for(let m=o+3;m<h;m+=2)if((a[m+1]&r)>0){let b=a[m];if(d.allows(b)&&(e.token.value==-1||e.token.value==b||Nd(b,e.token.value,l,s))){e.acceptToken(b);break}}let f=e.next,c=0,p=a[o+2];if(e.next<0&&p>c&&a[h+p*3-3]==65535){o=a[h+p*3-1];continue e}for(;c<p;){let m=c+p>>1,b=h+m+(m<<1),y=a[b],w=a[b+1]||65536;if(f<y)p=m;else if(f>=w)c=m+1;else{o=a[b+2],e.advance();continue e}}break}}function $l(a,e,t){for(let n=e,l;(l=a[n])!=65535;n++)if(l==t)return n-e;return-1}function Nd(a,e,t,n){let l=$l(t,n,e);return l<0||$l(t,n,a)<l}const Oe=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let hn=null;function Rl(a,e,t){let n=a.cursor(pe.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(a.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:a.length}}class Bd{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Rl(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Rl(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],l=this.index[t];if(l==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[l],o=this.start[t]+n.positions[l];if(o>e)return this.nextStart=o,null;if(s instanceof he){if(o==e){if(o<this.safeFrom)return null;let r=o+s.length;if(r<=this.safeTo){let d=s.prop(te.lookAhead);if(!d||r+d<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class Od{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new ki)}getActions(e){let t=0,n=null,{parser:l}=e.p,{tokenizers:s}=l,o=l.stateSlot(e.state,3),r=e.curContext?e.curContext.hash:0,d=0;for(let h=0;h<s.length;h++){if(!(1<<h&o))continue;let f=s[h],c=this.tokens[h];if(!(n&&!f.fallback)&&((f.contextual||c.start!=e.pos||c.mask!=o||c.context!=r)&&(this.updateCachedToken(c,f,e),c.mask=o,c.context=r),c.lookAhead>c.end+25&&(d=Math.max(c.lookAhead,d)),c.value!=0)){let p=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!f.extend&&(n=c,t>p))break}}for(;this.actions.length>t;)this.actions.pop();return d&&e.setLookAhead(d),!n&&e.pos==this.stream.end&&(n=new ki,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ki,{pos:n,p:l}=e;return t.start=n,t.end=Math.min(n+1,l.stream.end),t.value=n==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,n){let l=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(l,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let r=s.specializers[o](this.stream.read(e.start,e.end),n);if(r>=0&&n.p.parser.dialect.allows(r>>1)){r&1?e.extended=r>>1:e.value=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,n,l){for(let s=0;s<l;s+=3)if(this.actions[s]==e)return l;return this.actions[l++]=e,this.actions[l++]=t,this.actions[l++]=n,l}addActions(e,t,n,l){let{state:s}=e,{parser:o}=e.p,{data:r}=o;for(let d=0;d<2;d++)for(let h=o.stateSlot(s,d?2:1);;h+=3){if(r[h]==65535)if(r[h+1]==1)h=Qe(r,h+2);else{l==0&&r[h+1]==2&&(l=this.putAction(Qe(r,h+2),t,n,l));break}r[h]==t&&(l=this.putAction(Qe(r,h+1),t,n,l))}return l}}class Vd{constructor(e,t,n,l){this.parser=e,this.input=t,this.ranges=l,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Cd(t,l),this.tokens=new Od(e,this.stream),this.topTerm=e.top[1];let{from:s}=l[0];this.stacks=[pi.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new Bd(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],l,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let r=e[o];for(;;){if(this.tokens.mainToken=null,r.pos>t)n.push(r);else{if(this.advanceStack(r,n,e))continue;{l||(l=[],s=[]),l.push(r);let d=this.tokens.getMainToken(r);s.push(d.value,d.end)}}break}}if(!n.length){let o=l&&Md(l);if(o)return Oe&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Oe&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let o=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,s,n);if(o)return Oe&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((r,d)=>d.score-r.score);n.length>o;)n.pop();n.some(r=>r.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let r=n[o];for(let d=o+1;d<n.length;d++){let h=n[d];if(r.sameState(h)||r.buffer.length>500&&h.buffer.length>500)if((r.score-h.score||r.buffer.length-h.buffer.length)>0)n.splice(d--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let l=e.pos,{parser:s}=this,o=Oe?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,f=h?e.curContext.hash:0;for(let c=this.fragments.nodeAt(l);c;){let p=this.parser.nodeSet.types[c.type.id]==c.type?s.getGoto(e.state,c.type.id):-1;if(p>-1&&c.length&&(!h||(c.prop(te.contextHash)||0)==f))return e.useNode(c,p),Oe&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(c.type.id)})`),!0;if(!(c instanceof he)||c.children.length==0||c.positions[0]>0)break;let m=c.children[0];if(m instanceof he&&c.positions[0]==0)c=m;else break}}let r=s.stateSlot(e.state,4);if(r>0)return e.reduce(r),Oe&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(r&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let d=this.tokens.getActions(e);for(let h=0;h<d.length;){let f=d[h++],c=d[h++],p=d[h++],m=h==d.length||!n,b=m?e:e.split(),y=this.tokens.mainToken;if(b.apply(f,c,y?y.start:b.pos,p),Oe&&console.log(o+this.stackID(b)+` (via ${f&65536?`reduce of ${s.getName(f&65535)}`:"shift"} for ${s.getName(c)} @ ${l}${b==e?"":", split"})`),m)return!0;b.pos>l?t.push(b):n.push(b)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Ll(e,t),!0}}runRecovery(e,t,n){let l=null,s=!1;for(let o=0;o<e.length;o++){let r=e[o],d=t[o<<1],h=t[(o<<1)+1],f=Oe?this.stackID(r)+" -> ":"";if(r.deadEnd&&(s||(s=!0,r.restart(),Oe&&console.log(f+this.stackID(r)+" (restarted)"),this.advanceFully(r,n))))continue;let c=r.split(),p=f;for(let m=0;c.forceReduce()&&m<10&&(Oe&&console.log(p+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,n));m++)Oe&&(p=this.stackID(c)+" -> ");for(let m of r.recoverByInsert(d))Oe&&console.log(f+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,n);this.stream.end>r.pos?(h==r.pos&&(h++,d=0),r.recoverByDelete(d,h),Oe&&console.log(f+this.stackID(r)+` (via recover-delete ${this.parser.getName(d)})`),Ll(r,n)):(!l||l.score<r.score)&&(l=r)}return l}stackToTree(e){return e.close(),he.build({buffer:mi.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(hn||(hn=new WeakMap)).get(e);return t||hn.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Ll(a,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==a.pos&&n.sameState(a)){e[t].score<a.score&&(e[t]=a);return}}e.push(a)}class _d{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class bi extends Dl{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let r=0;r<e.repeatNodeCount;r++)t.push("");let n=Object.keys(e.topRules).map(r=>e.topRules[r][1]),l=[];for(let r=0;r<t.length;r++)l.push([]);function s(r,d,h){l[r].push([d,d.deserialize(String(h))])}if(e.nodeProps)for(let r of e.nodeProps){let d=r[0];typeof d=="string"&&(d=te[d]);for(let h=1;h<r.length;){let f=r[h++];if(f>=0)s(f,d,r[h++]);else{let c=r[h+-f];for(let p=-f;p>0;p--)s(r[h++],d,c);h++}}}this.nodeSet=new sn(t.map((r,d)=>Ne.define({name:d>=this.minRepeatTerm?void 0:r,id:d,props:l[d],top:n.indexOf(d)>-1,error:d==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(d)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Vl;let o=gi(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let r=0;r<this.specializerSpecs.length;r++)this.specialized[r]=this.specializerSpecs[r].term;this.specializers=this.specializerSpecs.map(jl),this.states=gi(e.states,Uint32Array),this.data=gi(e.stateData),this.goto=gi(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(r=>typeof r=="number"?new vt(o,r):r),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let l=new Vd(this,e,t,n);for(let s of this.wrappers)l=s(l,e,t,n);return l}getGoto(e,t,n=!1){let l=this.goto;if(t>=l[0])return-1;for(let s=l[t+1];;){let o=l[s++],r=o&1,d=l[s++];if(r&&n)return d;for(let h=s+(o>>1);s<h;s++)if(l[s]==e)return d;if(r)return-1}}hasAction(e,t){let n=this.data;for(let l=0;l<2;l++)for(let s=this.stateSlot(e,l?2:1),o;;s+=3){if((o=n[s])==65535)if(n[s+1]==1)o=n[s=Qe(n,s+2)];else{if(n[s+1]==2)return Qe(n,s+2);break}if(o==t||o==0)return Qe(n,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),l=n?t(n):void 0;for(let s=this.stateSlot(e,1);l==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Qe(this.data,s+2);else break;l=t(Qe(this.data,s+1))}return l}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Qe(this.data,n+2);else break;if(!(this.data[n+2]&1)){let l=this.data[n+1];t.some((s,o)=>o&1&&s==l)||t.push(this.data[n],l)}}return t}configure(e){let t=Object.assign(Object.create(bi.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let l=e.tokenizers.find(s=>s.from==n);return l?l.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,l)=>{let s=e.specializers.find(r=>r.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[l]=jl(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let l=null;for(let s=0;s<t.length;s++)if(!n[s])for(let o=this.dialects[t[s]],r;(r=this.data[o++])!=65535;)(l||(l=new Uint8Array(this.maxTerm+1)))[r]=1;return new _d(e,n,l)}static deserialize(e){return new bi(e)}}function Qe(a,e){return a[e]|a[e+1]<<16}function Md(a){let e=null;for(let t of a){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function jl(a){if(a.external){let e=a.extend?1:0;return(t,n)=>a.external(t,n)<<1|e}return a.get}let Td=0;class Te{constructor(e,t,n,l){this.name=e,this.set=t,this.base=n,this.modified=l,this.id=Td++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Te&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let l=new Te(n,[],null,[]);if(l.set.push(l),t)for(let s of t.set)l.set.push(s);return l}static defineModifier(e){let t=new yi(e);return n=>n.modified.indexOf(t)>-1?n:yi.get(n.base||n,n.modified.concat(t).sort((l,s)=>l.id-s.id))}}let Ad=0;class yi{constructor(e){this.name=e,this.instances=[],this.id=Ad++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(r=>r.base==e&&Ed(t,r.modified));if(n)return n;let l=[],s=new Te(e.name,l,e,t);for(let r of t)r.instances.push(s);let o=Id(t);for(let r of e.set)if(!r.modified.length)for(let d of o)l.push(yi.get(r,d));return s}}function Ed(a,e){return a.length==e.length&&a.every((t,n)=>t==e[n])}function Id(a){let e=[[]];for(let t=0;t<a.length;t++)for(let n=0,l=e.length;n<l;n++)e.push(e[n].concat(a[t]));return e.sort((t,n)=>n.length-t.length)}function zl(a){let e=Object.create(null);for(let t in a){let n=a[t];Array.isArray(n)||(n=[n]);for(let l of t.split(" "))if(l){let s=[],o=2,r=l;for(let c=0;;){if(r=="..."&&c>0&&c+3==l.length){o=1;break}let p=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!p)throw new RangeError("Invalid path: "+l);if(s.push(p[0]=="*"?"":p[0][0]=='"'?JSON.parse(p[0]):p[0]),c+=p[0].length,c==l.length)break;let m=l[c++];if(c==l.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+l);r=l.slice(c)}let d=s.length-1,h=s[d];if(!h)throw new RangeError("Invalid path: "+l);let f=new fn(n,o,d>0?s.slice(0,d):null);e[h]=f.sort(e[h])}}return Dd.add(e)}const Dd=new te;class fn{constructor(e,t,n,l){this.tags=e,this.mode=t,this.context=n,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}fn.empty=new fn([],2,null);function ql(a,e){let t=Object.create(null);for(let s of a)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:l=null}=e||{};return{style:s=>{let o=l;for(let r of s)for(let d of r.set){let h=t[d.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}const q=Te.define,wi=q(),nt=q(),Ul=q(nt),Wl=q(nt),lt=q(),xi=q(lt),un=q(lt),$e=q(),pt=q($e),Re=q(),Le=q(),pn=q(),Ut=q(pn),vi=q(),z={comment:wi,lineComment:q(wi),blockComment:q(wi),docComment:q(wi),name:nt,variableName:q(nt),typeName:Ul,tagName:q(Ul),propertyName:Wl,attributeName:q(Wl),className:q(nt),labelName:q(nt),namespace:q(nt),macroName:q(nt),literal:lt,string:xi,docString:q(xi),character:q(xi),attributeValue:q(xi),number:un,integer:q(un),float:q(un),bool:q(lt),regexp:q(lt),escape:q(lt),color:q(lt),url:q(lt),keyword:Re,self:q(Re),null:q(Re),atom:q(Re),unit:q(Re),modifier:q(Re),operatorKeyword:q(Re),controlKeyword:q(Re),definitionKeyword:q(Re),moduleKeyword:q(Re),operator:Le,derefOperator:q(Le),arithmeticOperator:q(Le),logicOperator:q(Le),bitwiseOperator:q(Le),compareOperator:q(Le),updateOperator:q(Le),definitionOperator:q(Le),typeOperator:q(Le),controlOperator:q(Le),punctuation:pn,separator:q(pn),bracket:Ut,angleBracket:q(Ut),squareBracket:q(Ut),paren:q(Ut),brace:q(Ut),content:$e,heading:pt,heading1:q(pt),heading2:q(pt),heading3:q(pt),heading4:q(pt),heading5:q(pt),heading6:q(pt),contentSeparator:q($e),list:q($e),quote:q($e),emphasis:q($e),strong:q($e),link:q($e),monospace:q($e),strikethrough:q($e),inserted:q(),deleted:q(),changed:q(),invalid:q(),meta:vi,documentMeta:q(vi),annotation:q(vi),processingInstruction:q(vi),definition:Te.defineModifier("definition"),constant:Te.defineModifier("constant"),function:Te.defineModifier("function"),standard:Te.defineModifier("standard"),local:Te.defineModifier("local"),special:Te.defineModifier("special")};for(let a in z){let e=z[a];e instanceof Te&&(e.name=a)}ql([{tag:z.link,class:"tok-link"},{tag:z.heading,class:"tok-heading"},{tag:z.emphasis,class:"tok-emphasis"},{tag:z.strong,class:"tok-strong"},{tag:z.keyword,class:"tok-keyword"},{tag:z.atom,class:"tok-atom"},{tag:z.bool,class:"tok-bool"},{tag:z.url,class:"tok-url"},{tag:z.labelName,class:"tok-labelName"},{tag:z.inserted,class:"tok-inserted"},{tag:z.deleted,class:"tok-deleted"},{tag:z.literal,class:"tok-literal"},{tag:z.string,class:"tok-string"},{tag:z.number,class:"tok-number"},{tag:[z.regexp,z.escape,z.special(z.string)],class:"tok-string2"},{tag:z.variableName,class:"tok-variableName"},{tag:z.local(z.variableName),class:"tok-variableName tok-local"},{tag:z.definition(z.variableName),class:"tok-variableName tok-definition"},{tag:z.special(z.variableName),class:"tok-variableName2"},{tag:z.definition(z.propertyName),class:"tok-propertyName tok-definition"},{tag:z.typeName,class:"tok-typeName"},{tag:z.namespace,class:"tok-namespace"},{tag:z.className,class:"tok-className"},{tag:z.macroName,class:"tok-macroName"},{tag:z.propertyName,class:"tok-propertyName"},{tag:z.operator,class:"tok-operator"},{tag:z.comment,class:"tok-comment"},{tag:z.meta,class:"tok-meta"},{tag:z.invalid,class:"tok-invalid"},{tag:z.punctuation,class:"tok-punctuation"}]);const Pd=zl({String:z.string,Number:z.number,"True False":z.bool,PropertyName:z.propertyName,Null:z.null,",":z.separator,"[ ]":z.squareBracket,"{ }":z.brace}),Fd=bi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[Pd],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});class ie{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ct(this,e,t);let l=[];return this.decompose(0,e,l,2),n.length&&n.decompose(0,n.length,l,3),this.decompose(t,this.length,l,1),je.from(l,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ct(this,e,t);let n=[];return this.decompose(e,t,n,0),je.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),l=new Wt(this),s=new Wt(e);for(let o=t,r=t;;){if(l.next(o),s.next(o),o=0,l.lineBreak!=s.lineBreak||l.done!=s.done||l.value!=s.value)return!1;if(r+=l.value.length,l.done||r>=n)return!0}}iter(e=1){return new Wt(this,e)}iterRange(e,t=this.length){return new Kl(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;n=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ql(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ie.empty:e.length<=32?new ce(e):je.from(ce.split(e,[]))}}class ce extends ie{constructor(e,t=$d(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,l){for(let s=0;;s++){let o=this.text[s],r=l+o.length;if((t?n:r)>=e)return new Rd(l,r,n,o);l=r+1,n++}}decompose(e,t,n,l){let s=e<=0&&t>=this.length?this:new ce(Hl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let o=n.pop(),r=Ci(s.text,o.text.slice(),0,s.length);if(r.length<=32)n.push(new ce(r,o.length+s.length));else{let d=r.length>>1;n.push(new ce(r.slice(0,d)),new ce(r.slice(d)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);[e,t]=Ct(this,e,t);let l=Ci(this.text,Ci(n.text,Hl(this.text,0,e)),t),s=this.length+n.length-(t-e);return l.length<=32?new ce(l,s):je.from(ce.split(l,[]),s)}sliceString(e,t=this.length,n=`
2
+ `){[e,t]=Ct(this,e,t);let l="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let r=this.text[o],d=s+r.length;s>e&&o&&(l+=n),e<d&&t>s&&(l+=r.slice(Math.max(0,e-s),t-s)),s=d+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],l=-1;for(let s of e)n.push(s),l+=s.length+1,n.length==32&&(t.push(new ce(n,l)),n=[],l=-1);return l>-1&&t.push(new ce(n,l)),t}}class je extends ie{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,l){for(let s=0;;s++){let o=this.children[s],r=l+o.length,d=n+o.lines-1;if((t?d:r)>=e)return o.lineInner(e,t,n,l);l=r+1,n=d+1}}decompose(e,t,n,l){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let r=this.children[s],d=o+r.length;if(e<=d&&t>=o){let h=l&((o<=e?1:0)|(d>=t?2:0));o>=e&&d<=t&&!h?n.push(r):r.decompose(e-o,t-o,n,h)}o=d+1}}replace(e,t,n){if([e,t]=Ct(this,e,t),n.lines<this.lines)for(let l=0,s=0;l<this.children.length;l++){let o=this.children[l],r=s+o.length;if(e>=s&&t<=r){let d=o.replace(e-s,t-s,n),h=this.lines-o.lines+d.lines;if(d.lines<h>>4&&d.lines>h>>6){let f=this.children.slice();return f[l]=d,new je(f,this.length-(t-e)+n.length)}return super.replace(s,r,d)}s=r+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
3
+ `){[e,t]=Ct(this,e,t);let l="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let r=this.children[s],d=o+r.length;o>e&&s&&(l+=n),e<d&&t>o&&(l+=r.sliceString(e-o,t-o,n)),o=d+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof je))return 0;let n=0,[l,s,o,r]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,s+=t){if(l==o||s==r)return n;let d=this.children[l],h=e.children[s];if(d!=h)return n+d.scanIdentical(h,t);n+=d.length+1}}static from(e,t=e.reduce((n,l)=>n+l.length+1,-1)){let n=0;for(let m of e)n+=m.lines;if(n<32){let m=[];for(let b of e)b.flatten(m);return new ce(m,t)}let l=Math.max(32,n>>5),s=l<<1,o=l>>1,r=[],d=0,h=-1,f=[];function c(m){let b;if(m.lines>s&&m instanceof je)for(let y of m.children)c(y);else m.lines>o&&(d>o||!d)?(p(),r.push(m)):m instanceof ce&&d&&(b=f[f.length-1])instanceof ce&&m.lines+b.lines<=32?(d+=m.lines,h+=m.length+1,f[f.length-1]=new ce(b.text.concat(m.text),b.length+1+m.length)):(d+m.lines>l&&p(),d+=m.lines,h+=m.length+1,f.push(m))}function p(){d!=0&&(r.push(f.length==1?f[0]:je.from(f,h)),h=-1,d=f.length=0)}for(let m of e)c(m);return p(),r.length==1?r[0]:new je(r,t)}}ie.empty=new ce([""],0);function $d(a){let e=-1;for(let t of a)e+=t.length+1;return e}function Ci(a,e,t=0,n=1e9){for(let l=0,s=0,o=!0;s<a.length&&l<=n;s++){let r=a[s],d=l+r.length;d>=t&&(d>n&&(r=r.slice(0,n-l)),l<t&&(r=r.slice(t-l)),o?(e[e.length-1]+=r,o=!1):e.push(r)),l=d+1}return e}function Hl(a,e,t){return Ci(a,[""],e,t)}class Wt{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,l=this.nodes[n],s=this.offsets[n],o=s>>1,r=l instanceof ce?l.text.length:l.children.length;if(o==(t>0?r:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
4
+ `,this;e--}else if(l instanceof ce){let d=l.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,d.length>Math.max(0,e))return this.value=e==0?d:t>0?d.slice(e):d.slice(0,d.length-e),this;e-=d.length}else{let d=l.children[o+(t<0?-1:0)];e>d.length?(e-=d.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(d),this.offsets.push(t>0?1:(d instanceof ce?d.text.length:d.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Kl{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Wt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=n?l:t<0?l.slice(l.length-n):l.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ql{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ie.prototype[Symbol.iterator]=function(){return this.iter()},Wt.prototype[Symbol.iterator]=Kl.prototype[Symbol.iterator]=Ql.prototype[Symbol.iterator]=function(){return this});class Rd{constructor(e,t,n,l){this.from=e,this.to=t,this.number=n,this.text=l}get length(){return this.to-this.from}}function Ct(a,e,t){return e=Math.max(0,Math.min(a.length,e)),[e,Math.max(e,Math.min(a.length,t))]}let St="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(a=>a?parseInt(a,36):1);for(let a=1;a<St.length;a++)St[a]+=St[a-1];function Ld(a){for(let e=1;e<St.length;e+=2)if(St[e]>a)return St[e-1]<=a;return!1}function Gl(a){return a>=127462&&a<=127487}const Yl=8205;function Ge(a,e,t=!0,n=!0){return(t?Xl:jd)(a,e,n)}function Xl(a,e,t){if(e==a.length)return e;e&&Jl(a.charCodeAt(e))&&Zl(a.charCodeAt(e-1))&&e--;let n=mn(a,e);for(e+=es(n);e<a.length;){let l=mn(a,e);if(n==Yl||l==Yl||t&&Ld(l))e+=es(l),n=l;else if(Gl(l)){let s=0,o=e-2;for(;o>=0&&Gl(mn(a,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function jd(a,e,t){for(;e>0;){let n=Xl(a,e-2,t);if(n<e)return n;e--}return 0}function Jl(a){return a>=56320&&a<57344}function Zl(a){return a>=55296&&a<56320}function mn(a,e){let t=a.charCodeAt(e);if(!Zl(t)||e+1==a.length)return t;let n=a.charCodeAt(e+1);return Jl(n)?(t-55296<<10)+(n-56320)+65536:t}function es(a){return a<65536?1:2}const gn=/\r\n?|\n/;var Ve=function(a){return a[a.Simple=0]="Simple",a[a.TrackDel=1]="TrackDel",a[a.TrackBefore=2]="TrackBefore",a[a.TrackAfter=3]="TrackAfter",a}(Ve||(Ve={}));class Ye{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,l=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,l,s),l+=s):l+=o,n+=s}}iterChangedRanges(e,t=!1){kn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],l=this.sections[t++];l<0?e.push(n,l):e.push(l,n)}return new Ye(e)}composeDesc(e){return this.empty?e:e.empty?this:ts(this,e)}mapDesc(e,t=!1){return e.empty?this:bn(this,e,t)}mapPos(e,t=-1,n=Ve.Simple){let l=0,s=0;for(let o=0;o<this.sections.length;){let r=this.sections[o++],d=this.sections[o++],h=l+r;if(d<0){if(h>e)return s+(e-l);s+=r}else{if(n!=Ve.Simple&&h>=e&&(n==Ve.TrackDel&&l<e&&h>e||n==Ve.TrackBefore&&l<e||n==Ve.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!r)return e==l||t<0?s:s+d;s+=d}l=h}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return s}touchesRange(e,t=e){for(let n=0,l=0;n<this.sections.length&&l<=t;){let s=this.sections[n++],o=this.sections[n++],r=l+s;if(o>=0&&l<=t&&r>=e)return l<e&&r>t?"cover":!0;l=r}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],l=this.sections[t++];e+=(e?" ":"")+n+(l>=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ye(e)}static create(e){return new Ye(e)}}class me extends Ye{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return kn(this,(t,n,l,s,o)=>e=e.replace(l,l+(n-t),o),!1),e}mapDesc(e,t=!1){return bn(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let l=0,s=0;l<t.length;l+=2){let o=t[l],r=t[l+1];if(r>=0){t[l]=r,t[l+1]=o;let d=l>>1;for(;n.length<d;)n.push(ie.empty);n.push(o?e.slice(s,s+o):ie.empty)}s+=o}return new me(t,n)}compose(e){return this.empty?e:e.empty?this:ts(this,e,!0)}map(e,t=!1){return e.empty?this:bn(this,e,t,!0)}iterChanges(e,t=!1){kn(this,e,t)}get desc(){return Ye.create(this.sections)}filter(e){let t=[],n=[],l=[],s=new Ht(this);e:for(let o=0,r=0;;){let d=o==e.length?1e9:e[o++];for(;r<d||r==d&&s.len==0;){if(s.done)break e;let f=Math.min(s.len,d-r);we(l,f,-1);let c=s.ins==-1?-1:s.off==0?s.ins:0;we(t,f,c),c>0&&st(n,t,s.text),s.forward(f),r+=f}let h=e[o++];for(;r<h;){if(s.done)break e;let f=Math.min(s.len,h-r);we(t,f,-1),we(l,f,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(f),r+=f}}return{changes:new me(t,n),filtered:Ye.create(l)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],l=this.sections[t+1];l<0?e.push(n):l==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let l=[],s=[],o=0,r=null;function d(f=!1){if(!f&&!l.length)return;o<t&&we(l,t-o,-1);let c=new me(l,s);r=r?r.compose(c.map(r)):c,l=[],s=[],o=0}function h(f){if(Array.isArray(f))for(let c of f)h(c);else if(f instanceof me){if(f.length!=t)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${t})`);d(),r=r?r.compose(f.map(r)):f}else{let{from:c,to:p=c,insert:m}=f;if(c>p||c<0||p>t)throw new RangeError(`Invalid change range ${c} to ${p} (in doc of length ${t})`);let b=m?typeof m=="string"?ie.of(m.split(n||gn)):m:ie.empty,y=b.length;if(c==p&&y==0)return;c<o&&d(),c>o&&we(l,c-o,-1),we(l,p-c,y),st(s,l,b),o=p}}return h(e),d(!r),r}static empty(e){return new me(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let l=0;l<e.length;l++){let s=e[l];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,r)=>r&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<l;)n.push(ie.empty);n[l]=ie.of(s.slice(1)),t.push(s[0],n[l].length)}}}return new me(t,n)}static createSet(e,t){return new me(e,t)}}function we(a,e,t,n=!1){if(e==0&&t<=0)return;let l=a.length-2;l>=0&&t<=0&&t==a[l+1]?a[l]+=e:e==0&&a[l]==0?a[l+1]+=t:n?(a[l]+=e,a[l+1]+=t):a.push(e,t)}function st(a,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<a.length)a[a.length-1]=a[a.length-1].append(t);else{for(;a.length<n;)a.push(ie.empty);a.push(t)}}function kn(a,e,t){let n=a.inserted;for(let l=0,s=0,o=0;o<a.sections.length;){let r=a.sections[o++],d=a.sections[o++];if(d<0)l+=r,s+=r;else{let h=l,f=s,c=ie.empty;for(;h+=r,f+=d,d&&n&&(c=c.append(n[o-2>>1])),!(t||o==a.sections.length||a.sections[o+1]<0);)r=a.sections[o++],d=a.sections[o++];e(l,h,s,f,c),l=h,s=f}}}function bn(a,e,t,n=!1){let l=[],s=n?[]:null,o=new Ht(a),r=new Ht(e);for(let d=-1;;)if(o.ins==-1&&r.ins==-1){let h=Math.min(o.len,r.len);we(l,h,-1),o.forward(h),r.forward(h)}else if(r.ins>=0&&(o.ins<0||d==o.i||o.off==0&&(r.len<o.len||r.len==o.len&&!t))){let h=r.len;for(we(l,r.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&d<o.i&&o.len<=f&&(we(l,0,o.ins),s&&st(s,l,o.text),d=o.i),o.forward(f),h-=f}r.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(r.ins==-1){let c=Math.min(f,r.len);h+=c,f-=c,r.forward(c)}else if(r.ins==0&&r.len<f)f-=r.len,r.next();else break;we(l,h,d<o.i?o.ins:0),s&&d<o.i&&st(s,l,o.text),d=o.i,o.forward(o.len-f)}else{if(o.done&&r.done)return s?me.createSet(l,s):Ye.create(l);throw new Error("Mismatched change set lengths")}}function ts(a,e,t=!1){let n=[],l=t?[]:null,s=new Ht(a),o=new Ht(e);for(let r=!1;;){if(s.done&&o.done)return l?me.createSet(n,l):Ye.create(n);if(s.ins==0)we(n,s.len,0,r),s.next();else if(o.len==0&&!o.done)we(n,0,o.ins,r),l&&st(l,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let d=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;we(n,d,f,r),l&&f&&st(l,n,o.text)}else o.ins==-1?(we(n,s.off?0:s.len,d,r),l&&st(l,n,s.textBit(d))):(we(n,s.off?0:s.len,o.off?0:o.ins,r),l&&!o.off&&st(l,n,o.text));r=(s.ins>d||o.ins>=0&&o.len>d)&&(r||n.length>h),s.forward2(d),o.forward(d)}}}}class Ht{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ie.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ie.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class mt{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,l;return this.empty?n=l=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),n==this.from&&l==this.to?this:new mt(n,l,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return H.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return H.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return H.range(e.anchor,e.head)}static create(e,t,n){return new mt(e,t,n)}}class H{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:H.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new H([this.main],0)}addRange(e,t=!0){return H.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,H.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new H(e.ranges.map(t=>mt.fromJSON(t)),e.main)}static single(e,t=e){return new H([H.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,l=0;l<e.length;l++){let s=e[l];if(s.empty?s.from<=n:s.from<n)return H.normalized(e.slice(),t);n=s.to}return new H(e,t)}static cursor(e,t=0,n,l){return mt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(l??16777215)<<6)}static range(e,t,n,l){let s=(n??16777215)<<6|(l==null?7:Math.min(6,l));return t<e?mt.create(t,e,48|s):mt.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((l,s)=>l.from-s.from),t=e.indexOf(n);for(let l=1;l<e.length;l++){let s=e[l],o=e[l-1];if(s.empty?s.from<=o.to:s.from<o.to){let r=o.from,d=Math.max(s.to,o.to);l<=t&&t--,e.splice(--l,2,s.anchor>s.head?H.range(d,r):H.range(r,d))}}return new H(e,t)}}function is(a,e){for(let t of a.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let yn=0;class Y{constructor(e,t,n,l,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=l,this.id=yn++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Y(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:wn),!!e.static,e.enables)}of(e){return new Si([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Si(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Si(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function wn(a,e){return a==e||a.length==e.length&&a.every((t,n)=>t===e[n])}class Si{constructor(e,t,n,l){this.dependencies=e,this.facet=t,this.type=n,this.value=l,this.id=yn++}dynamicSlot(e){var t;let n=this.value,l=this.facet.compareInput,s=this.id,o=e[s]>>1,r=this.type==2,d=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?d=!0:c=="selection"?h=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||f.push(e[c.id]);return{create(c){return c.values[o]=n(c),1},update(c,p){if(d&&p.docChanged||h&&(p.docChanged||p.selection)||xn(c,f)){let m=n(c);if(r?!ns(m,c.values[o],l):!l(m,c.values[o]))return c.values[o]=m,1}return 0},reconfigure:(c,p)=>{let m,b=p.config.address[s];if(b!=null){let y=Oi(p,b);if(this.dependencies.every(w=>w instanceof Y?p.facet(w)===c.facet(w):w instanceof gt?p.field(w,!1)==c.field(w,!1):!0)||(r?ns(m=n(c),y,l):l(m=n(c),y)))return c.values[o]=y,0}else m=n(c);return c.values[o]=m,1}}}}function ns(a,e,t){if(a.length!=e.length)return!1;for(let n=0;n<a.length;n++)if(!t(a[n],e[n]))return!1;return!0}function xn(a,e){let t=!1;for(let n of e)Qt(a,n)&1&&(t=!0);return t}function zd(a,e,t){let n=t.map(d=>a[d.id]),l=t.map(d=>d.type),s=n.filter(d=>!(d&1)),o=a[e.id]>>1;function r(d){let h=[];for(let f=0;f<n.length;f++){let c=Oi(d,n[f]);if(l[f]==2)for(let p of c)h.push(p);else h.push(c)}return e.combine(h)}return{create(d){for(let h of n)Qt(d,h);return d.values[o]=r(d),1},update(d,h){if(!xn(d,s))return 0;let f=r(d);return e.compare(f,d.values[o])?0:(d.values[o]=f,1)},reconfigure(d,h){let f=xn(d,n),c=h.config.facets[e.id],p=h.facet(e);if(c&&!f&&wn(t,c))return d.values[o]=p,0;let m=r(d);return e.compare(m,p)?(d.values[o]=p,0):(d.values[o]=m,1)}}}const ls=Y.define({static:!0});class gt{constructor(e,t,n,l,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=l,this.spec=s,this.provides=void 0}static define(e){let t=new gt(yn++,e.create,e.update,e.compare||((n,l)=>n===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ls).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,l)=>{let s=n.values[t],o=this.updateF(s,l);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,l)=>l.config.address[this.id]!=null?(n.values[t]=l.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,ls.of({field:this,create:e})]}get extension(){return this}}const kt={lowest:4,low:3,default:2,high:1,highest:0};function Kt(a){return e=>new ss(e,a)}const qd={highest:Kt(kt.highest),high:Kt(kt.high),default:Kt(kt.default),low:Kt(kt.low),lowest:Kt(kt.lowest)};class ss{constructor(e,t){this.inner=e,this.prec=t}}class Ni{of(e){return new vn(this,e)}reconfigure(e){return Ni.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class vn{constructor(e,t){this.compartment=e,this.inner=t}}class Bi{constructor(e,t,n,l,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=l,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let l=[],s=Object.create(null),o=new Map;for(let p of Ud(e,t,o))p instanceof gt?l.push(p):(s[p.facet.id]||(s[p.facet.id]=[])).push(p);let r=Object.create(null),d=[],h=[];for(let p of l)r[p.id]=h.length<<1,h.push(m=>p.slot(m));let f=n?.config.facets;for(let p in s){let m=s[p],b=m[0].facet,y=f&&f[p]||[];if(m.every(w=>w.type==0))if(r[b.id]=d.length<<1|1,wn(y,m))d.push(n.facet(b));else{let w=b.combine(m.map(v=>v.value));d.push(n&&b.compare(w,n.facet(b))?n.facet(b):w)}else{for(let w of m)w.type==0?(r[w.id]=d.length<<1|1,d.push(w.value)):(r[w.id]=h.length<<1,h.push(v=>w.dynamicSlot(v)));r[b.id]=h.length<<1,h.push(w=>zd(w,b,m))}}let c=h.map(p=>p(r));return new Bi(e,o,c,r,d,s)}}function Ud(a,e,t){let n=[[],[],[],[],[]],l=new Map;function s(o,r){let d=l.get(o);if(d!=null){if(d<=r)return;let h=n[d].indexOf(o);h>-1&&n[d].splice(h,1),o instanceof vn&&t.delete(o.compartment)}if(l.set(o,r),Array.isArray(o))for(let h of o)s(h,r);else if(o instanceof vn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,r)}else if(o instanceof ss)s(o.inner,o.prec);else if(o instanceof gt)n[r].push(o),o.provides&&s(o.provides,r);else if(o instanceof Si)n[r].push(o),o.facet.extensions&&s(o.facet.extensions,kt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,r)}}return s(a,kt.default),n.reduce((o,r)=>o.concat(r))}function Qt(a,e){if(e&1)return 2;let t=e>>1,n=a.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;a.status[t]=4;let l=a.computeSlot(a,a.config.dynamicSlots[t]);return a.status[t]=2|l}function Oi(a,e){return e&1?a.config.staticValues[e>>1]:a.values[e>>1]}const os=Y.define(),Cn=Y.define({combine:a=>a.some(e=>e),static:!0}),as=Y.define({combine:a=>a.length?a[0]:void 0,static:!0}),rs=Y.define(),ds=Y.define(),cs=Y.define(),hs=Y.define({combine:a=>a.length?a[0]:!1});class Nt{constructor(e,t){this.type=e,this.value=t}static define(){return new Wd}}class Wd{of(e){return new Nt(this,e)}}class Hd{constructor(e){this.map=e}of(e){return new ue(this,e)}}class ue{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ue(this.type,t)}is(e){return this.type==e}static define(e={}){return new Hd(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let l of e){let s=l.map(t);s&&n.push(s)}return n}}ue.reconfigure=ue.define(),ue.appendConfig=ue.define();class xe{constructor(e,t,n,l,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=l,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&is(n,t.newLength),s.some(r=>r.type==xe.time)||(this.annotations=s.concat(xe.time.of(Date.now())))}static create(e,t,n,l,s,o){return new xe(e,t,n,l,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(xe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}xe.time=Nt.define(),xe.userEvent=Nt.define(),xe.addToHistory=Nt.define(),xe.remote=Nt.define();function Kd(a,e){let t=[];for(let n=0,l=0;;){let s,o;if(n<a.length&&(l==e.length||e[l]>=a[n]))s=a[n++],o=a[n++];else if(l<e.length)s=e[l++],o=e[l++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function fs(a,e,t){var n;let l,s,o;return t?(l=e.changes,s=me.empty(e.changes.length),o=a.changes.compose(e.changes)):(l=e.changes.map(a.changes),s=a.changes.mapDesc(e.changes,!0),o=a.changes.compose(l)),{changes:o,selection:e.selection?e.selection.map(s):(n=a.selection)===null||n===void 0?void 0:n.map(l),effects:ue.mapEffects(a.effects,l).concat(ue.mapEffects(e.effects,s)),annotations:a.annotations.length?a.annotations.concat(e.annotations):e.annotations,scrollIntoView:a.scrollIntoView||e.scrollIntoView}}function Sn(a,e,t){let n=e.selection,l=Bt(e.annotations);return e.userEvent&&(l=l.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,a.facet(as)),selection:n&&(n instanceof H?n:H.single(n.anchor,n.head)),effects:Bt(e.effects),annotations:l,scrollIntoView:!!e.scrollIntoView}}function us(a,e,t){let n=Sn(a,e.length?e[0]:{},a.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=fs(n,Sn(a,e[s],o?n.changes.newLength:a.doc.length),o)}let l=xe.create(a,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Gd(t?Qd(l):l)}function Qd(a){let e=a.startState,t=!0;for(let l of e.facet(rs)){let s=l(a);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Kd(t,s))}if(t!==!0){let l,s;if(t===!1)s=a.changes.invertedDesc,l=me.empty(e.doc.length);else{let o=a.changes.filter(t);l=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}a=xe.create(e,l,a.selection&&a.selection.map(s),ue.mapEffects(a.effects,s),a.annotations,a.scrollIntoView)}let n=e.facet(ds);for(let l=n.length-1;l>=0;l--){let s=n[l](a);s instanceof xe?a=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?a=s[0]:a=us(e,Bt(s),!1)}return a}function Gd(a){let e=a.startState,t=e.facet(cs),n=a;for(let l=t.length-1;l>=0;l--){let s=t[l](a);s&&Object.keys(s).length&&(n=fs(n,Sn(e,s,a.changes.newLength),!0))}return n==a?a:xe.create(e,a.changes,a.selection,n.effects,n.annotations,n.scrollIntoView)}const Yd=[];function Bt(a){return a==null?Yd:Array.isArray(a)?a:[a]}var Xe=function(a){return a[a.Word=0]="Word",a[a.Space=1]="Space",a[a.Other=2]="Other",a}(Xe||(Xe={}));const Xd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Nn;try{Nn=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Jd(a){if(Nn)return Nn.test(a);for(let e=0;e<a.length;e++){let t=a[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Xd.test(t)))return!0}return!1}function Zd(a){return e=>{if(!/\S/.test(e))return Xe.Space;if(Jd(e))return Xe.Word;for(let t=0;t<a.length;t++)if(e.indexOf(a[t])>-1)return Xe.Word;return Xe.Other}}class se{constructor(e,t,n,l,s,o){this.config=e,this.doc=t,this.selection=n,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let r=0;r<this.config.dynamicSlots.length;r++)Qt(this,r<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Qt(this,n),Oi(this,n)}update(...e){return us(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:l}=t;for(let r of e.effects)r.is(Ni.reconfigure)?(t&&(l=new Map,t.compartments.forEach((d,h)=>l.set(h,d)),t=null),l.set(r.value.compartment,r.value.extension)):r.is(ue.reconfigure)?(t=null,n=r.value):r.is(ue.appendConfig)&&(t=null,n=Bt(n).concat(r.value));let s;t?s=e.startState.values.slice():(t=Bi.resolve(n,l,this),s=new se(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(d,h)=>h.reconfigure(d,this),null).values);let o=e.startState.facet(Cn)?e.newSelection:e.newSelection.asSingle();new se(t,e.newDoc,o,s,(r,d)=>d.update(r,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:H.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),l=this.changes(n.changes),s=[n.range],o=Bt(n.effects);for(let r=1;r<t.ranges.length;r++){let d=e(t.ranges[r]),h=this.changes(d.changes),f=h.map(l);for(let p=0;p<r;p++)s[p]=s[p].map(f);let c=l.mapDesc(h,!0);s.push(d.range.map(c)),l=l.compose(f),o=ue.mapEffects(o,f).concat(ue.mapEffects(Bt(d.effects),c))}return{changes:l,selection:H.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(se.lineSeparator))}toText(e){return ie.of(e.split(this.facet(se.lineSeparator)||gn))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Qt(this,t),Oi(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let l=e[n];l instanceof gt&&this.config.address[l.id]!=null&&(t[n]=l.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let l=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],r=e[s];l.push(o.init(d=>o.spec.fromJSON(r,d)))}}return se.create({doc:e.doc,selection:H.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=Bi.resolve(e.extensions||[],new Map),n=e.doc instanceof ie?e.doc:ie.of((e.doc||"").split(t.staticFacet(se.lineSeparator)||gn)),l=e.selection?e.selection instanceof H?e.selection:H.single(e.selection.anchor,e.selection.head):H.single(0);return is(l,n.length),t.staticFacet(Cn)||(l=l.asSingle()),new se(t,n,l,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(se.tabSize)}get lineBreak(){return this.facet(se.lineSeparator)||`
5
+ `}get readOnly(){return this.facet(hs)}phrase(e,...t){for(let n of this.facet(se.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,l)=>{if(l=="$")return"$";let s=+(l||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let l=[];for(let s of this.facet(os))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&l.push(o[e]);return l}charCategorizer(e){return Zd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:l}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,r=e-n;for(;o>0;){let d=Ge(t,o,!1);if(s(t.slice(d,o))!=Xe.Word)break;o=d}for(;r<l;){let d=Ge(t,r);if(s(t.slice(r,d))!=Xe.Word)break;r=d}return o==r?null:H.range(o+n,r+n)}}se.allowMultipleSelections=Cn,se.tabSize=Y.define({combine:a=>a.length?a[0]:4}),se.lineSeparator=as,se.readOnly=hs,se.phrases=Y.define({compare(a,e){let t=Object.keys(a),n=Object.keys(e);return t.length==n.length&&t.every(l=>a[l]==e[l])}}),se.languageData=os,se.changeFilter=rs,se.transactionFilter=ds,se.transactionExtender=cs,Ni.reconfigure=ue.define();class Ot{eq(e){return this==e}range(e,t=e){return Gt.create(e,t,this)}}Ot.prototype.startSide=Ot.prototype.endSide=0,Ot.prototype.point=!1,Ot.prototype.mapMode=Ve.TrackDel;class Gt{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Gt(e,t,n)}}function Bn(a,e){return a.from-e.from||a.value.startSide-e.value.startSide}class On{constructor(e,t,n,l){this.from=e,this.to=t,this.value=n,this.maxPoint=l}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,l=0){let s=n?this.to:this.from;for(let o=l,r=s.length;;){if(o==r)return o;let d=o+r>>1,h=s[d]-e||(n?this.value[d].endSide:this.value[d].startSide)-t;if(d==o)return h>=0?o:r;h>=0?r=d:o=d+1}}between(e,t,n,l){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(l(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],l=[],s=[],o=-1,r=-1;for(let d=0;d<this.value.length;d++){let h=this.value[d],f=this.from[d]+e,c=this.to[d]+e,p,m;if(f==c){let b=t.mapPos(f,h.startSide,h.mapMode);if(b==null||(p=m=b,h.startSide!=h.endSide&&(m=t.mapPos(f,h.endSide),m<p)))continue}else if(p=t.mapPos(f,h.startSide),m=t.mapPos(c,h.endSide),p>m||p==m&&h.startSide>0&&h.endSide<=0)continue;(m-p||h.endSide-h.startSide)<0||(o<0&&(o=p),h.point&&(r=Math.max(r,m-p)),n.push(h),l.push(p-o),s.push(m-o))}return{mapped:n.length?new On(l,s,n,r):null,pos:o}}}class re{constructor(e,t,n,l){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=l}static create(e,t,n,l){return new re(e,t,n,l)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:l=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Bn)),this.isEmpty)return t.length?re.of(t):this;let r=new ms(this,null,-1).goto(0),d=0,h=[],f=new Vi;for(;r.value||d<t.length;)if(d<t.length&&(r.from-t[d].from||r.startSide-t[d].value.startSide)>=0){let c=t[d++];f.addInner(c.from,c.to,c.value)||h.push(c)}else r.rangeIndex==1&&r.chunkIndex<this.chunk.length&&(d==t.length||this.chunkEnd(r.chunkIndex)<t[d].from)&&(!o||l>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&f.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!o||l>r.to||s<r.from||o(r.from,r.to,r.value))&&(f.addInner(r.from,r.to,r.value)||h.push(Gt.create(r.from,r.to,r.value))),r.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?re.empty:this.nextLayer.update({add:h,filter:o,filterFrom:l,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],l=-1;for(let o=0;o<this.chunk.length;o++){let r=this.chunkPos[o],d=this.chunk[o],h=e.touchesRange(r,r+d.length);if(h===!1)l=Math.max(l,d.maxPoint),t.push(d),n.push(e.mapPos(r));else if(h===!0){let{mapped:f,pos:c}=d.map(r,e);f&&(l=Math.max(l,f.maxPoint),t.push(f),n.push(c))}}let s=this.nextLayer.map(e);return t.length==0?s:new re(n,t,s||re.empty,l)}between(e,t,n){if(!this.isEmpty){for(let l=0;l<this.chunk.length;l++){let s=this.chunkPos[l],o=this.chunk[l];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Yt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Yt.from(e).goto(t)}static compare(e,t,n,l,s=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),r=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),d=ps(o,r,n),h=new Xt(o,d,s),f=new Xt(r,d,s);n.iterGaps((c,p,m)=>gs(h,c,f,p,m,l)),n.empty&&n.length==0&&gs(h,0,f,0,0,l)}static eq(e,t,n=0,l){l==null&&(l=999999999);let s=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),o=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let r=ps(s,o),d=new Xt(s,r,0).goto(n),h=new Xt(o,r,0).goto(n);for(;;){if(d.to!=h.to||!_n(d.active,h.active)||d.point&&(!h.point||!d.point.eq(h.point)))return!1;if(d.to>l)return!0;d.next(),h.next()}}static spans(e,t,n,l,s=-1){let o=new Xt(e,null,s).goto(t),r=t,d=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFrom<t?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,d);l.point(r,h,o.point,f,c,o.pointRank),d=Math.min(o.openEnd(h),f.length)}else h>r&&(l.span(r,h,o.active,d),d=o.openEnd(h));if(o.to>n)return d+(o.point&&o.to>n?1:0);r=o.to,o.next()}}static of(e,t=!1){let n=new Vi;for(let l of e instanceof Gt?[e]:t?ec(e):e)n.add(l.from,l.to,l.value);return n.finish()}static join(e){if(!e.length)return re.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let l=e[n];l!=re.empty;l=l.nextLayer)t=new re(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}re.empty=new re([],[],null,-1);function ec(a){if(a.length>1)for(let e=a[0],t=1;t<a.length;t++){let n=a[t];if(Bn(e,n)>0)return a.slice().sort(Bn);e=n}return a}re.empty.nextLayer=re.empty;class Vi{finishChunk(e){this.chunks.push(new On(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Vi)).add(e,t,n)}addInner(e,t,n){let l=e-this.lastTo||n.startSide-this.last.endSide;if(l<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return l<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(re.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=re.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ps(a,e,t){let n=new Map;for(let s of a)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let l=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let r=n.get(s.chunk[o]);r!=null&&(t?t.mapPos(r):r)==s.chunkPos[o]&&!t?.touchesRange(r,r+s.chunk[o].length)&&l.add(s.chunk[o])}return l}class ms{constructor(e,t,n,l=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=l}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let l=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(l)||this.layer.chunkEnd(this.chunkIndex)<e||l.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let l=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<l)&&this.setRangeIndex(l)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Yt{constructor(e){this.heap=e}static from(e,t=null,n=-1){let l=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&l.push(new ms(o,t,n,s));return l.length==1?l[0]:new Yt(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Vn(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Vn(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Vn(this.heap,0)}}}function Vn(a,e){for(let t=a[e];;){let n=(e<<1)+1;if(n>=a.length)break;let l=a[n];if(n+1<a.length&&l.compare(a[n+1])>=0&&(l=a[n+1],n++),t.compare(l)<0)break;a[n]=t,a[e]=l,e=n}}class Xt{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Yt.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){_i(this.active,e),_i(this.activeTo,e),_i(this.activeRank,e),this.minActive=ks(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:l,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||l-this.activeTo[t])>0;)t++;Mi(this.active,t,n),Mi(this.activeTo,t,l),Mi(this.activeRank,t,s),e&&Mi(e,t,this.cursor.from),this.minActive=ks(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),n&&_i(n,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let l=n.length-1;l>=0&&n[l]<e;l--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function gs(a,e,t,n,l,s){a.goto(e),t.goto(n);let o=n+l,r=n,d=n-e;for(;;){let h=a.to+d-t.to||a.endSide-t.endSide,f=h<0?a.to+d:t.to,c=Math.min(f,o);if(a.point||t.point?a.point&&t.point&&(a.point==t.point||a.point.eq(t.point))&&_n(a.activeForPoint(a.to),t.activeForPoint(t.to))||s.comparePoint(r,c,a.point,t.point):c>r&&!_n(a.active,t.active)&&s.compareRange(r,c,a.active,t.active),f>o)break;r=f,h<=0&&a.next(),h>=0&&t.next()}}function _n(a,e){if(a.length!=e.length)return!1;for(let t=0;t<a.length;t++)if(a[t]!=e[t]&&!a[t].eq(e[t]))return!1;return!0}function _i(a,e){for(let t=e,n=a.length-1;t<n;t++)a[t]=a[t+1];a.pop()}function Mi(a,e,t){for(let n=a.length-1;n>=e;n--)a[n+1]=a[n];a[e]=t}function ks(a,e){let t=-1,n=1e9;for(let l=0;l<e.length;l++)(e[l]-n||a[l].endSide-a[t].endSide)<0&&(t=l,n=e[l]);return t}function tc(a,e,t,n){for(let l=0,s=0;;){if(s>=e)return l;if(l==a.length)break;s+=a.charCodeAt(l)==9?t-s%t:1,l=Ge(a,l)}return n===!0?-1:a.length}const Mn="ͼ",bs=typeof Symbol>"u"?"__"+Mn:Symbol.for(Mn),Tn=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ys=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ot{constructor(e,t){this.rules=[];let{finish:n}=t||{};function l(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,r,d,h){let f=[],c=/^@(\w+)\b/.exec(o[0]),p=c&&c[1]=="keyframes";if(c&&r==null)return d.push(o[0]+";");for(let m in r){let b=r[m];if(/&/.test(m))s(m.split(/,\s*/).map(y=>o.map(w=>y.replace(/&/,w))).reduce((y,w)=>y.concat(w)),b,d);else if(b&&typeof b=="object"){if(!c)throw new RangeError("The value of a property ("+m+") should be a primitive value.");s(l(m),b,f,p)}else b!=null&&f.push(m.replace(/_.*/,"").replace(/[A-Z]/g,y=>"-"+y.toLowerCase())+": "+b+";")}(f.length||p)&&d.push((n&&!c&&!h?o.map(n):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)s(l(o),e[o],this.rules)}getRules(){return this.rules.join(`
6
+ `)}static newName(){let e=ys[bs]||1;return ys[bs]=e+1,Mn+e.toString(36)}static mount(e,t,n){let l=e[Tn],s=n&&n.nonce;l?s&&l.setNonce(s):l=new ic(e,s),l.mount(Array.isArray(t)?t:[t],e)}}let ws=new Map;class ic{constructor(e,t){let n=e.ownerDocument||e,l=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let s=ws.get(n);if(s)return e[Tn]=s;this.sheet=new l.CSSStyleSheet,ws.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Tn]=this}mount(e,t){let n=this.sheet,l=0,s=0;for(let o=0;o<e.length;o++){let r=e[o],d=this.modules.indexOf(r);if(d<s&&d>-1&&(this.modules.splice(d,1),s--,d=-1),d==-1){if(this.modules.splice(s++,0,r),n)for(let h=0;h<r.rules.length;h++)n.insertRule(r.rules[h],l++)}else{for(;s<d;)l+=this.modules[s++].rules.length;l+=r.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let d=0;d<this.modules.length;d++)o+=this.modules[d].getRules()+`
7
+ `;this.styleTag.textContent=o;let r=t.head||t;this.styleTag.parentNode!=r&&r.insertBefore(this.styleTag,r.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Vt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ke=0;ke<10;ke++)Vt[48+ke]=Vt[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Vt[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Vt[ke]=String.fromCharCode(ke+32),An[ke]=String.fromCharCode(ke);for(var En in Vt)An.hasOwnProperty(En)||(An[En]=Vt[En]);function Jt(a){let e;return a.nodeType==11?e=a.getSelection?a:a.ownerDocument:e=a,e.getSelection()}function In(a,e){return e?a==e||a.contains(e.nodeType!=1?e.parentNode:e):!1}function nc(a){let e=a.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ti(a,e){if(!e.anchorNode)return!1;try{return In(a,e.anchorNode)}catch{return!1}}function Zt(a){return a.nodeType==3?yt(a,0,a.nodeValue.length).getClientRects():a.nodeType==1?a.getClientRects():[]}function ei(a,e,t,n){return t?xs(a,e,t,n,-1)||xs(a,e,t,n,1):!1}function bt(a){for(var e=0;;e++)if(a=a.previousSibling,!a)return e}function Ai(a){return a.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(a.nodeName)}function xs(a,e,t,n,l){for(;;){if(a==t&&e==n)return!0;if(e==(l<0?0:Je(a))){if(a.nodeName=="DIV")return!1;let s=a.parentNode;if(!s||s.nodeType!=1)return!1;e=bt(a)+(l<0?0:1),a=s}else if(a.nodeType==1){if(a=a.childNodes[e+(l<0?-1:0)],a.nodeType==1&&a.contentEditable=="false")return!1;e=l<0?Je(a):0}else return!1}}function Je(a){return a.nodeType==3?a.nodeValue.length:a.childNodes.length}function Ei(a,e){let t=e?a.left:a.right;return{left:t,right:t,top:a.top,bottom:a.bottom}}function lc(a){let e=a.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:a.innerWidth,top:0,bottom:a.innerHeight}}function vs(a,e){let t=e.width/a.offsetWidth,n=e.height/a.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-a.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-a.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function sc(a,e,t,n,l,s,o,r){let d=a.ownerDocument,h=d.defaultView||window;for(let f=a,c=!1;f&&!c;)if(f.nodeType==1){let p,m=f==d.body,b=1,y=1;if(m)p=lc(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let k=f.getBoundingClientRect();({scaleX:b,scaleY:y}=vs(f,k)),p={left:k.left,right:k.left+f.clientWidth*b,top:k.top,bottom:k.top+f.clientHeight*y}}let w=0,v=0;if(l=="nearest")e.top<p.top?(v=-(p.top-e.top+o),t>0&&e.bottom>p.bottom+v&&(v=e.bottom-p.bottom+v+o)):e.bottom>p.bottom&&(v=e.bottom-p.bottom+o,t<0&&e.top-v<p.top&&(v=-(p.top+v-e.top+o)));else{let k=e.bottom-e.top,O=p.bottom-p.top;v=(l=="center"&&k<=O?e.top+k/2-O/2:l=="start"||l=="center"&&t<0?e.top-o:e.bottom-O+o)-p.top}if(n=="nearest"?e.left<p.left?(w=-(p.left-e.left+s),t>0&&e.right>p.right+w&&(w=e.right-p.right+w+s)):e.right>p.right&&(w=e.right-p.right+s,t<0&&e.left<p.left+w&&(w=-(p.left+w-e.left+s))):w=(n=="center"?e.left+(e.right-e.left)/2-(p.right-p.left)/2:n=="start"==r?e.left-s:e.right-(p.right-p.left)+s)-p.left,w||v)if(m)h.scrollBy(w,v);else{let k=0,O=0;if(v){let g=f.scrollTop;f.scrollTop+=v/y,O=(f.scrollTop-g)*y}if(w){let g=f.scrollLeft;f.scrollLeft+=w/b,k=(f.scrollLeft-g)*b}e={left:e.left-k,top:e.top-O,right:e.right-k,bottom:e.bottom-O},k&&Math.abs(k-w)<1&&(n="nearest"),O&&Math.abs(O-v)<1&&(l="nearest")}if(m)break;f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function oc(a){let e=a.ownerDocument,t,n;for(let l=a.parentNode;l&&!(l==e.body||t&&n);)if(l.nodeType==1)!n&&l.scrollHeight>l.clientHeight&&(n=l),!t&&l.scrollWidth>l.clientWidth&&(t=l),l=l.assignedSlot||l.parentNode;else if(l.nodeType==11)l=l.host;else break;return{x:t,y:n}}class ac{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Je(t):0),n,Math.min(e.focusOffset,n?Je(n):0))}set(e,t,n,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=l}}let _t=null;function Cs(a){if(a.setActive)return a.setActive();if(_t)return a.focus(_t);let e=[];for(let t=a;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(a.focus(_t==null?{get preventScroll(){return _t={preventScroll:!0},!0}}:void 0),!_t){_t=!1;for(let t=0;t<e.length;){let n=e[t++],l=e[t++],s=e[t++];n.scrollTop!=l&&(n.scrollTop=l),n.scrollLeft!=s&&(n.scrollLeft=s)}}}let Ss;function yt(a,e,t=e){let n=Ss||(Ss=document.createRange());return n.setEnd(a,t),n.setStart(a,e),n}function Mt(a,e,t,n){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=n);let s=new KeyboardEvent("keydown",l);s.synthetic=!0,a.dispatchEvent(s);let o=new KeyboardEvent("keyup",l);return o.synthetic=!0,a.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function rc(a){for(;a;){if(a&&(a.nodeType==9||a.nodeType==11&&a.host))return a;a=a.assignedSlot||a.parentNode}return null}function Ns(a){for(;a.attributes.length;)a.removeAttributeNode(a.attributes[0])}function dc(a,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Je(t));;)if(n){if(t.nodeType!=1)return!1;let l=t.childNodes[n-1];l.contentEditable=="false"?n--:(t=l,n=Je(t))}else{if(t==a)return!0;n=bt(t),t=t.parentNode}}function Bs(a){return a.scrollTop>Math.max(1,a.scrollHeight-a.clientHeight-4)}function Os(a,e){for(let t=a,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Je(t)}else if(t.parentNode&&!Ai(t))n=bt(t),t=t.parentNode;else return null}}function Vs(a,e){for(let t=a,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!Ai(t))n=bt(t)+1,t=t.parentNode;else return null}}class ve{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new ve(e.parentNode,bt(e),t)}static after(e,t){return new ve(e.parentNode,bt(e)+1,t)}}const Dn=[];class oe{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,l=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=l?l.nextSibling:n.firstChild)){let r=oe.get(s);(!r||!r.parent&&r.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=l?l.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=_s(s);else n.insertBefore(o.dom,s);l=o.dom}for(s=l?l.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=_s(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let l=Je(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;l==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?l=-1:l=1),e=s}l<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!oe.get(n);)n=n.nextSibling;if(!n)return this.length;for(let l=0,s=0;;l++){let o=this.children[l];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let l=-1,s=-1,o=-1,r=-1;for(let d=0,h=n,f=n;d<this.children.length;d++){let c=this.children[d],p=h+c.length;if(h<e&&p>t)return c.domBoundsAround(e,t,h);if(p>=e&&l==-1&&(l=d,s=h),h>t&&c.dom.parentNode==this.dom){o=d,r=f;break}f=p,h=p+c.breakAfter}return{from:s,to:r<0?n+this.length:r,startDOM:(l?this.children[l-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Dn){this.markDirty();for(let l=e;l<t;l++){let s=this.children[l];s.parent==this&&n.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...n);for(let l=0;l<n.length;l++)n[l].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Ms(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,l,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}oe.prototype.breakAfter=0;function _s(a){let e=a.nextSibling;return a.parentNode.removeChild(a),e}class Ms{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Ts(a,e,t,n,l,s,o,r,d){let{children:h}=a,f=h.length?h[e]:null,c=s.length?s[s.length-1]:null,p=c?c.breakAfter:o;if(!(e==n&&f&&!o&&!p&&s.length<2&&f.merge(t,l,s.length?c:null,t==0,r,d))){if(n<h.length){let m=h[n];m&&(l<m.length||m.breakAfter&&c?.breakAfter)?(e==n&&(m=m.split(l),l=0),!p&&c&&m.merge(0,l,c,!0,0,d)?s[s.length-1]=m:((l||m.children.length&&!m.children[0].length)&&m.merge(0,l,null,!1,0,d),s.push(m))):m?.breakAfter&&(c?c.breakAfter=1:o=1),n++}for(f&&(f.breakAfter=o,t>0&&(!o&&s.length&&f.merge(t,f.length,s[0],!1,r,0)?f.breakAfter=s.shift().breakAfter:(t<f.length||f.children.length&&f.children[f.children.length-1].length==0)&&f.merge(t,f.length,null,!1,r,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),d=s.length?0:r;else if(h[e].become(s[0]))e++,s.shift(),r=s.length?0:d;else break;!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,r,d)&&e--,(e<n||s.length)&&a.replaceChildren(e,n,s)}}function As(a,e,t,n,l,s){let o=a.childCursor(),{i:r,off:d}=o.findPos(t,1),{i:h,off:f}=o.findPos(e,-1),c=e-t;for(let p of n)c+=p.length;a.length+=c,Ts(a,h,f,r,d,n,0,l,s)}let Be=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Pn=typeof document<"u"?document:{documentElement:{style:{}}};const Fn=/Edge\/(\d+)/.exec(Be.userAgent),Es=/MSIE \d/.test(Be.userAgent),$n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Be.userAgent),Ii=!!(Es||$n||Fn),Is=!Ii&&/gecko\/(\d+)/i.test(Be.userAgent),Rn=!Ii&&/Chrome\/(\d+)/.exec(Be.userAgent),Ds="webkitFontSmoothing"in Pn.documentElement.style,Ps=!Ii&&/Apple Computer/.test(Be.vendor),Fs=Ps&&(/Mobile\/\w+/.test(Be.userAgent)||Be.maxTouchPoints>2);var W={mac:Fs||/Mac/.test(Be.platform),windows:/Win/.test(Be.platform),linux:/Linux|X11/.test(Be.platform),ie:Ii,ie_version:Es?Pn.documentMode||6:$n?+$n[1]:Fn?+Fn[1]:0,gecko:Is,gecko_version:Is?+(/Firefox\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,chrome:!!Rn,chrome_version:Rn?+Rn[1]:0,ios:Fs,android:/Android\b/.test(Be.userAgent),webkit:Ds,safari:Ps,webkit_version:Ds?+(/\bAppleWebKit\/(\d+)/.exec(Be.userAgent)||[0,0])[1]:0,tabSize:Pn.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const cc=256;class De extends oe{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof De)||this.length-(t-e)+n.length>cc||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new De(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new ve(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return hc(this.dom,e,t)}}class Ze extends oe{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let l of t)l.setParent(this)}setAttrs(e){if(Ns(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,l,s,o){return n&&(!(n instanceof Ze&&n.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(As(this,e,t,n?n.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,l=-1,s=0;for(let r of this.children){let d=n+r.length;d>e&&t.push(n<e?r.split(e-n):r),l<0&&n>=e&&(l=s),n=d,s++}let o=this.length-e;return this.length=e,l>-1&&(this.children.length=l,this.markDirty()),new Ze(this.mark,t,o)}domAtPos(e){return $s(this,e)}coordsAt(e,t){return Ls(this,e,t)}}function hc(a,e,t){let n=a.nodeValue.length;e>n&&(e=n);let l=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?W.chrome||W.gecko||(e?(l--,o=1):s<n&&(s++,o=-1)):t<0?l--:s<n&&s++;let r=yt(a,l,s).getClientRects();if(!r.length)return null;let d=r[(o?o<0:t>=0)?0:r.length-1];return W.safari&&!o&&d.width==0&&(d=Array.prototype.find.call(r,h=>h.width)||d),o?Ei(d,o<0):d||null}class wt extends oe{static create(e,t,n){return new wt(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=wt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,l,s,o){return n&&(!(n instanceof wt)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof wt&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return ie.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,l=this.posAtStart;return n?n.slice(l,l+this.length):ie.empty}domAtPos(e){return(this.length?e==0:this.side>0)?ve.before(this.dom):ve.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let l=this.dom.getClientRects(),s=null;if(!l.length)return null;let o=this.side?this.side<0:e>0;for(let r=o?l.length-1:0;s=l[r],!(e>0?r==0:r==l.length-1||s.top<s.bottom);r+=o?-1:1);return Ei(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Tt extends oe{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Tt&&e.side==this.side}split(){return new Tt(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?ve.before(this.dom):ve.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ie.empty}get isHidden(){return!0}}De.prototype.children=wt.prototype.children=Tt.prototype.children=Dn;function $s(a,e){let t=a.dom,{children:n}=a,l=0;for(let s=0;l<n.length;l++){let o=n[l],r=s+o.length;if(!(r==s&&o.getSide()<=0)){if(e>s&&e<r&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=r}}for(let s=l;s>0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=l;s<n.length;s++){let o=n[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new ve(t,0)}function Rs(a,e,t){let n,{children:l}=a;t>0&&e instanceof Ze&&l.length&&(n=l[l.length-1])instanceof Ze&&n.mark.eq(e.mark)?Rs(n,e.children[0],t-1):(l.push(e),e.setParent(a)),a.length+=e.length}function Ls(a,e,t){let n=null,l=-1,s=null,o=-1;function r(h,f){for(let c=0,p=0;c<h.children.length&&p<=f;c++){let m=h.children[c],b=p+m.length;b>=f&&(m.children.length?r(m,f-p):(!s||s.isHidden&&t>0)&&(b>f||p==b&&m.getSide()>0)?(s=m,o=f-p):(p<f||p==b&&m.getSide()<0&&!m.isHidden)&&(n=m,l=f-p)),p=b}}r(a,e);let d=(t<0?n:s)||n||s;return d?d.coordsAt(Math.max(0,d==n?l:o),t):fc(a)}function fc(a){let e=a.dom.lastChild;if(!e)return a.dom.getBoundingClientRect();let t=Zt(e);return t[t.length-1]||null}function Ln(a,e){for(let t in a)t=="class"&&e.class?e.class+=" "+a.class:t=="style"&&e.style?e.style+=";"+a.style:e[t]=a[t];return e}const js=Object.create(null);function Di(a,e,t){if(a==e)return!0;a||(a=js),e||(e=js);let n=Object.keys(a),l=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=l.length-(t&&l.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(l.indexOf(s)==-1||a[s]!==e[s]))return!1;return!0}function jn(a,e,t){let n=!1;if(e)for(let l in e)t&&l in t||(n=!0,l=="style"?a.style.cssText="":a.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(n=!0,l=="style"?a.style.cssText=t[l]:a.setAttribute(l,t[l]));return n}function uc(a){let e=Object.create(null);for(let t=0;t<a.attributes.length;t++){let n=a.attributes[t];e[n.name]=n.value}return e}class zn{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ze=function(a){return a[a.Text=0]="Text",a[a.WidgetBefore=1]="WidgetBefore",a[a.WidgetAfter=2]="WidgetAfter",a[a.WidgetRange=3]="WidgetRange",a}(ze||(ze={}));class Ce extends Ot{constructor(e,t,n,l){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=l}get heightRelevant(){return!1}static mark(e){return new ti(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new at(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,l;if(e.isBlockGap)n=-5e8,l=4e8;else{let{start:s,end:o}=zs(e,t);n=(s?t?-3e8:-1:5e8)-1,l=(o?t?2e8:1:-6e8)+1}return new at(e,n,l,t,e.widget||null,!0)}static line(e){return new ii(e)}static set(e,t=!1){return re.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ce.none=re.empty;class ti extends Ce{constructor(e){let{start:t,end:n}=zs(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ti&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&Di(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ti.prototype.point=!1;class ii extends Ce{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ii&&this.spec.class==e.spec.class&&Di(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ii.prototype.mapMode=Ve.TrackBefore,ii.prototype.point=!0;class at extends Ce{constructor(e,t,n,l,s,o){super(t,n,s,e),this.block=l,this.isReplace=o,this.mapMode=l?t<=0?Ve.TrackBefore:Ve.TrackAfter:Ve.TrackDel}get type(){return this.startSide!=this.endSide?ze.WidgetRange:this.startSide<=0?ze.WidgetBefore:ze.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof at&&pc(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}at.prototype.point=!0;function zs(a,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=a;return t==null&&(t=a.inclusive),n==null&&(n=a.inclusive),{start:t??e,end:n??e}}function pc(a,e){return a==e||!!(a&&e&&a.compare(e))}function qn(a,e,t,n=0){let l=t.length-1;l>=0&&t[l]+n>=a?t[l]=Math.max(t[l],e):t.push(a,e)}class fe extends oe{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,l,s,o){if(n){if(!(n instanceof fe))return!1;this.dom||n.transferDOM(this)}return l&&this.setDeco(n?n.attrs:null),As(this,e,t,n?n.children.slice():[],s,o),!0}split(e){let t=new fe;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:l}=this.childPos(e);l&&(t.append(this.children[n].split(l),0),this.children[n].merge(l,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)t.append(this.children[s],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Di(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Rs(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Ln(t,this.attrs||{})),n&&(this.attrs=Ln({class:n},this.attrs||{}))}domAtPos(e){return $s(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Ns(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(jn(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let l=this.dom.lastChild;for(;l&&oe.get(l)instanceof Ze;)l=l.lastChild;if(!l||!this.length||l.nodeName!="BR"&&((n=oe.get(l))===null||n===void 0?void 0:n.isEditable)==!1&&(!W.ios||!this.children.some(s=>s instanceof De))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof De)||/[^ -~]/.test(n.text))return null;let l=Zt(n.dom);if(l.length!=1)return null;e+=l[0].width,t=l[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=Ls(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:l}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-l.lineHeight)<2&&l.textHeight<s){let o=(s-l.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof fe&&this.children.length==0&&e.children.length==0&&Di(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,l=0;n<e.children.length;n++){let s=e.children[n],o=l+s.length;if(o>=t){if(s instanceof fe)return s;if(o>t)break}l=o+s.breakAfter}return null}}class et extends oe{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,l,s,o){return n&&(!(n instanceof et)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?ve.before(this.dom):ve.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new et(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Dn}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):ie.empty}domBoundsAround(){return null}become(e){return e instanceof et&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof Un?null:Ei(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}}class Un extends zn{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class ni{constructor(e,t,n,l){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=l,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof et&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new fe),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Pi(new Tt(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof et)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:r}=this.cursor.next(this.skip);if(this.skip=0,r)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let l=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Pi(new De(this.text.slice(this.textOff,this.textOff+l)),t),n),this.atCursorPos=!0,this.textOff+=l,e-=l,n=0}}span(e,t,n,l){this.buildText(t-e,n,l),this.pos=t,this.openStart<0&&(this.openStart=l)}point(e,t,n,l,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof at){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=t-e;if(n instanceof at)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new et(n.widget||At.block,r,n));else{let d=wt.create(n.widget||At.inline,r,r?0:n.startSide),h=this.atCursorPos&&!d.isEditable&&s<=l.length&&(e<t||n.startSide>0),f=!d.isEditable&&(e<t||s>l.length||n.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!h&&!d.isEditable&&(this.pendingBuffer=0),this.flushBuffer(l),h&&(c.append(Pi(new Tt(1),l),s),s=l.length+Math.max(0,s-l.length)),c.append(Pi(d,l),s),this.atCursorPos=f,this.pendingBuffer=f?e<t||s>l.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=l.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,l,s){let o=new ni(e,t,n,s);return o.openEnd=re.spans(l,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Pi(a,e){for(let t of e)a=new Ze(t,[a],a.length);return a}class At extends zn{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}At.inline=new At("span"),At.block=new At("div");var be=function(a){return a[a.LTR=0]="LTR",a[a.RTL=1]="RTL",a}(be||(be={}));const xt=be.LTR,Wn=be.RTL;function qs(a){let e=[];for(let t=0;t<a.length;t++)e.push(1<<+a[t]);return e}const mc=qs("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),gc=qs("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Hn=Object.create(null),qe=[];for(let a of["()","[]","{}"]){let e=a.charCodeAt(0),t=a.charCodeAt(1);Hn[e]=t,Hn[t]=-e}function Us(a){return a<=247?mc[a]:1424<=a&&a<=1524?2:1536<=a&&a<=1785?gc[a-1536]:1774<=a&&a<=2220?4:8192<=a&&a<=8204?256:64336<=a&&a<=65023?4:1}const kc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class rt{get dir(){return this.level%2?Wn:xt}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,l){let s=-1;for(let o=0;o<e.length;o++){let r=e[o];if(r.from<=t&&r.to>=t){if(r.level==n)return o;(s<0||(l!=0?l<0?r.from<t:r.to>t:e[s].level>r.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Ws(a,e){if(a.length!=e.length)return!1;for(let t=0;t<a.length;t++){let n=a[t],l=e[t];if(n.from!=l.from||n.to!=l.to||n.direction!=l.direction||!Ws(n.inner,l.inner))return!1}return!0}const ae=[];function bc(a,e,t,n,l){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,r=s<n.length?n[s].from:t,d=s?256:l;for(let h=o,f=d,c=d;h<r;h++){let p=Us(a.charCodeAt(h));p==512?p=f:p==8&&c==4&&(p=16),ae[h]=p==4?2:p,p&7&&(c=p),f=p}for(let h=o,f=d,c=d;h<r;h++){let p=ae[h];if(p==128)h<r-1&&f==ae[h+1]&&f&24?p=ae[h]=f:ae[h]=256;else if(p==64){let m=h+1;for(;m<r&&ae[m]==64;)m++;let b=h&&f==8||m<t&&ae[m]==8?c==1?1:8:256;for(let y=h;y<m;y++)ae[y]=b;h=m-1}else p==8&&c==1&&(ae[h]=1);f=p,p&7&&(c=p)}}}function yc(a,e,t,n,l){let s=l==1?2:1;for(let o=0,r=0,d=0;o<=n.length;o++){let h=o?n[o-1].to:e,f=o<n.length?n[o].from:t;for(let c=h,p,m,b;c<f;c++)if(m=Hn[p=a.charCodeAt(c)])if(m<0){for(let y=r-3;y>=0;y-=3)if(qe[y+1]==-m){let w=qe[y+2],v=w&2?l:w&4?w&1?s:l:0;v&&(ae[c]=ae[qe[y]]=v),r=y;break}}else{if(qe.length==189)break;qe[r++]=c,qe[r++]=p,qe[r++]=d}else if((b=ae[c])==2||b==1){let y=b==l;d=y?0:1;for(let w=r-3;w>=0;w-=3){let v=qe[w+2];if(v&2)break;if(y)qe[w+2]|=2;else{if(v&4)break;qe[w+2]|=4}}}}}function wc(a,e,t,n){for(let l=0,s=n;l<=t.length;l++){let o=l?t[l-1].to:a,r=l<t.length?t[l].from:e;for(let d=o;d<r;){let h=ae[d];if(h==256){let f=d+1;for(;;)if(f==r){if(l==t.length)break;f=t[l++].to,r=l<t.length?t[l].from:e}else if(ae[f]==256)f++;else break;let c=s==1,p=(f<e?ae[f]:n)==1,m=c==p?c?1:2:n;for(let b=f,y=l,w=y?t[y-1].to:a;b>d;)b==w&&(b=t[--y].from,w=y?t[y-1].to:a),ae[--b]=m;d=f}else s=h,d++}}}function Kn(a,e,t,n,l,s,o){let r=n%2?2:1;if(n%2==l%2)for(let d=e,h=0;d<t;){let f=!0,c=!1;if(h==s.length||d<s[h].from){let y=ae[d];y!=r&&(f=!1,c=y==16)}let p=!f&&r==1?[]:null,m=f?n:n+1,b=d;e:for(;;)if(h<s.length&&b==s[h].from){if(c)break e;let y=s[h];if(!f)for(let w=y.to,v=h+1;;){if(w==t)break e;if(v<s.length&&s[v].from==w)w=s[v++].to;else{if(ae[w]==r)break e;break}}if(h++,p)p.push(y);else{y.from>d&&o.push(new rt(d,y.from,m));let w=y.direction==xt!=!(m%2);Qn(a,w?n+1:n,l,y.inner,y.from,y.to,o),d=y.to}b=y.to}else{if(b==t||(f?ae[b]!=r:ae[b]==r))break;b++}p?Kn(a,d,b,n+1,l,p,o):d<b&&o.push(new rt(d,b,m)),d=b}else for(let d=t,h=s.length;d>e;){let f=!0,c=!1;if(!h||d>s[h-1].to){let y=ae[d-1];y!=r&&(f=!1,c=y==16)}let p=!f&&r==1?[]:null,m=f?n:n+1,b=d;e:for(;;)if(h&&b==s[h-1].to){if(c)break e;let y=s[--h];if(!f)for(let w=y.from,v=h;;){if(w==e)break e;if(v&&s[v-1].to==w)w=s[--v].from;else{if(ae[w-1]==r)break e;break}}if(p)p.push(y);else{y.to<d&&o.push(new rt(y.to,d,m));let w=y.direction==xt!=!(m%2);Qn(a,w?n+1:n,l,y.inner,y.from,y.to,o),d=y.from}b=y.from}else{if(b==e||(f?ae[b-1]!=r:ae[b-1]==r))break;b--}p?Kn(a,b,d,n+1,l,p,o):b<d&&o.push(new rt(b,d,m)),d=b}}function Qn(a,e,t,n,l,s,o){let r=e%2?2:1;bc(a,l,s,n,r),yc(a,l,s,n,r),wc(l,s,n,r),Kn(a,l,s,e,t,n,o)}function xc(a,e,t){if(!a)return[new rt(0,0,e==Wn?1:0)];if(e==xt&&!t.length&&!kc.test(a))return Hs(a.length);if(t.length)for(;a.length>ae.length;)ae[ae.length]=256;let n=[],l=e==xt?0:1;return Qn(a,l,l,t,0,a.length,n),n}function Hs(a){return[new rt(0,a,0)]}let Ks="";function vc(a,e,t,n,l){var s;let o=n.head-a.from,r=rt.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),d=e[r],h=d.side(l,t);if(o==h){let p=r+=l?1:-1;if(p<0||p>=e.length)return null;d=e[r=p],o=d.side(!l,t),h=d.side(l,t)}let f=Ge(a.text,o,d.forward(l,t));(f<d.from||f>d.to)&&(f=h),Ks=a.text.slice(Math.min(o,f),Math.max(o,f));let c=r==(l?e.length-1:0)?null:e[r+(l?1:-1)];return c&&f==h&&c.level+(l?0:1)<d.level?H.cursor(c.side(!l,t)+a.from,c.forward(l,t)?1:-1,c.level):H.cursor(f+a.from,d.forward(l,t)?-1:1,d.level)}function Cc(a,e,t){for(let n=e;n<t;n++){let l=Us(a.charCodeAt(n));if(l==1)return xt;if(l==2||l==4)return Wn}return xt}const Qs=Y.define(),Gs=Y.define(),Ys=Y.define(),Xs=Y.define(),Gn=Y.define(),Js=Y.define(),Zs=Y.define(),Yn=Y.define(),Xn=Y.define(),eo=Y.define({combine:a=>a.some(e=>e)}),Sc=Y.define({combine:a=>a.some(e=>e)}),to=Y.define();class Et{constructor(e,t="nearest",n="nearest",l=5,s=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=l,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Et(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Et(H.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Fi=ue.define({map:(a,e)=>a.map(e)}),io=ue.define();function Ue(a,e,t){let n=a.facet(Xs);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const dt=Y.define({combine:a=>a.length?a[0]:!0});let Nc=0;const li=Y.define();class It{constructor(e,t,n,l,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=l,this.extension=s(this)}static define(e,t){const{eventHandlers:n,eventObservers:l,provide:s,decorations:o}=t||{};return new It(Nc++,e,n,l,r=>{let d=[li.of(r)];return o&&d.push(si.of(h=>{let f=h.plugin(r);return f?o(f):Ce.none})),s&&d.push(s(r)),d})}static fromClass(e,t){return It.define(n=>new e(n),t)}}class Jn{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ue(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ue(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ue(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const no=Y.define(),Zn=Y.define(),si=Y.define(),lo=Y.define(),el=Y.define(),so=Y.define();function oo(a,e){let t=a.state.facet(so);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(a):s),l=[];return re.spans(n,e.from,e.to,{point(){},span(s,o,r,d){let h=s-e.from,f=o-e.from,c=l;for(let p=r.length-1;p>=0;p--,d--){let m=r[p].spec.bidiIsolate,b;if(m==null&&(m=Cc(e.text,h,f)),d>0&&c.length&&(b=c[c.length-1]).to==h&&b.direction==m)b.to=f,c=b.inner;else{let y={from:h,to:f,direction:m,inner:[]};c.push(y),c=y.inner}}}}),l}const ao=Y.define();function ro(a){let e=0,t=0,n=0,l=0;for(let s of a.state.facet(ao)){let o=s(a);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(l=Math.max(l,o.bottom)))}return{left:e,right:t,top:n,bottom:l}}const oi=Y.define();class Ae{constructor(e,t,n,l){this.fromA=e,this.toA=t,this.fromB=n,this.toB=l}join(e){return new Ae(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let l=e[t-1];if(!(l.fromA>n.toA)){if(l.toA<n.fromA)break;n=n.join(l),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let l=0,s=0,o=0,r=0;;l++){let d=l==e.length?null:e[l],h=o-r,f=d?d.fromB:1e9;for(;s<t.length&&t[s]<f;){let c=t[s],p=t[s+1],m=Math.max(r,c),b=Math.min(f,p);if(m<=b&&new Ae(m+h,b+h,m,b).addToSet(n),p>f)break;s+=2}if(!d)return n;new Ae(d.fromA,d.toA,d.fromB,d.toB).addToSet(n),o=d.toA,r=d.toB}}}class $i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=me.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let l=[];this.changes.iterChangedRanges((s,o,r,d)=>l.push(new Ae(s,o,r,d))),this.changedRanges=l}static create(e,t,n){return new $i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class co extends oe{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Ce.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new fe],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ae(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:f})=>f<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!Ac(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let s=l>-1?Oc(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;n=new Ae(h,f,e.changes.mapPos(h,-1),e.changes.mapPos(f,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(W.ie||W.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,r=this.updateDeco(),d=Mc(o,r,e.changes);return n=Ae.extendWithRanges(n,d),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:l}=this.view;l.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=W.chrome||W.ios?{node:l.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||l.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof et&&o.widget instanceof Un&&s.push(o.dom);l.updateGaps(s)}updateChildren(e,t,n){let l=n?n.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=l.length-1;;o--){let r=o>=0?l[o]:null;if(!r)break;let{fromA:d,toA:h,fromB:f,toB:c}=r,p,m,b,y;if(n&&n.range.fromB<c&&n.range.toB>f){let g=ni.build(this.view.state.doc,f,n.range.fromB,this.decorations,this.dynamicDecorationMap),u=ni.build(this.view.state.doc,n.range.toB,c,this.decorations,this.dynamicDecorationMap);m=g.breakAtStart,b=g.openStart,y=u.openEnd;let N=this.compositionView(n);u.breakAtStart?N.breakAfter=1:u.content.length&&N.merge(N.length,N.length,u.content[0],!1,u.openStart,0)&&(N.breakAfter=u.content[0].breakAfter,u.content.shift()),g.content.length&&N.merge(0,0,g.content[g.content.length-1],!0,0,g.openEnd)&&g.content.pop(),p=g.content.concat(N).concat(u.content)}else({content:p,breakAtStart:m,openStart:b,openEnd:y}=ni.build(this.view.state.doc,f,c,this.decorations,this.dynamicDecorationMap));let{i:w,off:v}=s.findPos(h,1),{i:k,off:O}=s.findPos(d,-1);Ts(this,k,O,w,v,p,m,b,y)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(io)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new De(e.text.nodeValue);t.flags|=8;for(let{deco:l}of e.marks)t=new Ze(l,[t],t.length);let n=new fe;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(d=>d.flags&7)?1:0),this.markedForComposition.add(o);let r=oe.get(s);r&&r!=o&&(r.dom=null),o.setDOM(s)},n=this.childPos(e.range.fromB,1),l=this.children[n.i];t(e.line,l);for(let s=e.marks.length-1;s>=-1;s--)n=l.childPos(n.off,1),l=l.children[n.i],t(s>=0?e.marks[s].node:e.text,l)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,l=n==this.dom,s=!l&&Ti(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(l||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,d=this.moveToLine(this.domAtPos(r.anchor)),h=r.empty?d:this.moveToLine(this.domAtPos(r.head));if(W.gecko&&r.empty&&!this.hasComposition&&Bc(d)){let c=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(c,d.node.childNodes[d.offset]||null)),d=h=new ve(c,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!ei(d.node,d.offset,f.anchorNode,f.anchorOffset)||!ei(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,r))&&(this.view.observer.ignore(()=>{W.android&&W.chrome&&this.dom.contains(f.focusNode)&&Tc(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=Jt(this.view.root);if(c)if(r.empty){if(W.gecko){let p=Vc(d.node,d.offset);if(p&&p!=3){let m=(p==1?Os:Vs)(d.node,d.offset);m&&(d=new ve(m.node,m.offset))}}c.collapse(d.node,d.offset),r.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=r.bidiLevel)}else if(c.extend){c.collapse(d.node,d.offset);try{c.extend(h.node,h.offset)}catch{}}else{let p=document.createRange();r.anchor>r.head&&([d,h]=[h,d]),p.setEnd(h.node,h.offset),p.setStart(d.node,d.offset),c.removeAllRanges(),c.addRange(p)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(d,h)),this.impreciseAnchor=d.precise?null:new ve(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new ve(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ei(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Jt(e.root),{anchorNode:l,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=fe.find(this,t.head);if(!o)return;let r=o.posAtStart;if(t.head==r||t.head==r+o.length)return;let d=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!d||!h||d.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc);n.collapse(f.node,f.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(l,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let l=e.offset;!n&&l<t.childNodes.length;l++){let s=oe.get(t.childNodes[l]);s instanceof fe&&(n=s.domAtPos(0))}for(let l=e.offset-1;!n&&l>=0;l--){let s=oe.get(t.childNodes[l]);s instanceof fe&&(n=s.domAtPos(s.length))}return n?new ve(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=oe.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let l=this.children[t];if(n<l.length||l instanceof fe)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,l=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let r=this.children[o],d=s-r.breakAfter,h=d-r.length;if(d<e)break;if(h<=e&&(h<e||r.covers(-1))&&(d>e||r.covers(1))&&(!n||r instanceof fe&&!(n instanceof fe&&t>=0)))n=r,l=h;else if(n&&h==e&&d==e&&r instanceof et&&Math.abs(t)<2){if(r.deco.startSide<0)break;o&&(n=null)}s=h}return n?n.coordsAt(e-l,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),l=this.children[t];if(!(l instanceof fe))return null;for(;l.children.length;){let{i:r,off:d}=l.childPos(n,1);for(;;r++){if(r==l.children.length)return null;if((l=l.children[r]).length)break}n=d}if(!(l instanceof De))return null;let s=Ge(l.text,n);if(s==n)return null;let o=yt(l.dom,n,s).getClientRects();for(let r=0;r<o.length;r++){let d=o[r];if(r==o.length-1||d.top<d.bottom&&d.left<d.right)return d}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:l}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,d=this.view.textDirection==be.LTR;for(let h=0,f=0;f<this.children.length;f++){let c=this.children[f],p=h+c.length;if(p>l)break;if(h>=n){let m=c.dom.getBoundingClientRect();if(t.push(m.height),o){let b=c.dom.lastChild,y=b?Zt(b):[];if(y.length){let w=y[y.length-1],v=d?w.right-m.left:m.right-w.left;v>r&&(r=v,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=p)}}}h=p+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?be.RTL:be.LTR}measureTextSize(){for(let s of this.children)if(s instanceof fe){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,l;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Zt(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,l=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:l}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Ms(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,l=0;;l++){let s=l==t.viewports.length?null:t.viewports[l],o=s?s.from-1:this.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Ce.replace({widget:new Un(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return Ce.set(e)}updateDeco(){let e=1,t=this.view.state.facet(si).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,l=this.view.state.facet(lo).map((s,o)=>{let r=typeof s=="function";return r&&(n=!0),r?s(this.view):s});for(l.length&&(this.dynamicDecorationMap[e++]=n,t.push(re.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(to))try{if(h(this.view,e.range,e))return!0}catch(f){Ue(this.view.state,f,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),l;if(!n)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,l.left),top:Math.min(n.top,l.top),right:Math.max(n.right,l.right),bottom:Math.max(n.bottom,l.bottom)});let s=ro(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:d}=this.view.scrollDOM;sc(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,r),-r),Math.max(Math.min(e.yMargin,d),-d),this.view.textDirection==be.LTR)}}function Bc(a){return a.node.nodeType==1&&a.node.firstChild&&(a.offset==0||a.node.childNodes[a.offset-1].contentEditable=="false")&&(a.offset==a.node.childNodes.length||a.node.childNodes[a.offset].contentEditable=="false")}function ho(a,e){let t=a.observer.selectionRange;if(!t.focusNode)return null;let n=Os(t.focusNode,t.focusOffset),l=Vs(t.focusNode,t.focusOffset),s=n||l;if(l&&n&&l.node!=n.node){let r=oe.get(l.node);if(!r||r instanceof De&&r.text!=l.node.nodeValue)s=l;else if(a.docView.lastCompositionAfterCursor){let d=oe.get(n.node);!d||d instanceof De&&d.text!=n.node.nodeValue||(s=l)}}if(a.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Oc(a,e,t){let n=ho(a,t);if(!n)return null;let{node:l,from:s,to:o}=n,r=l.nodeValue;if(/[\n\r]/.test(r)||a.state.doc.sliceString(n.from,n.to)!=r)return null;let d=e.invertedDesc,h=new Ae(d.mapPos(s),d.mapPos(o),s,o),f=[];for(let c=l.parentNode;;c=c.parentNode){let p=oe.get(c);if(p instanceof Ze)f.push({node:c,deco:p.mark});else{if(p instanceof fe||c.nodeName=="DIV"&&c.parentNode==a.contentDOM)return{range:h,text:l,marks:f,line:c};if(c!=a.contentDOM)f.push({node:c,deco:new ti({inclusive:!0,attributes:uc(c),tagName:c.tagName.toLowerCase()})});else return null}}}function Vc(a,e){return a.nodeType!=1?0:(e&&a.childNodes[e-1].contentEditable=="false"?1:0)|(e<a.childNodes.length&&a.childNodes[e].contentEditable=="false"?2:0)}let _c=class{constructor(){this.changes=[]}compareRange(e,t){qn(e,t,this.changes)}comparePoint(e,t){qn(e,t,this.changes)}};function Mc(a,e,t){let n=new _c;return re.compare(a,e,t,n),n.changes}function Tc(a,e){for(let t=a;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ac(a,e){let t=!1;return e&&a.iterChangedRanges((n,l)=>{n<e.to&&l>e.from&&(t=!0)}),t}function Ec(a,e,t=1){let n=a.charCategorizer(e),l=a.doc.lineAt(e),s=e-l.from;if(l.length==0)return H.cursor(e);s==0?t=1:s==l.length&&(t=-1);let o=s,r=s;t<0?o=Ge(l.text,s,!1):r=Ge(l.text,s);let d=n(l.text.slice(o,r));for(;o>0;){let h=Ge(l.text,o,!1);if(n(l.text.slice(h,o))!=d)break;o=h}for(;r<l.length;){let h=Ge(l.text,r);if(n(l.text.slice(r,h))!=d)break;r=h}return H.range(o+l.from,r+l.from)}function Ic(a,e){return e.left>a?e.left-a:Math.max(0,a-e.right)}function Dc(a,e){return e.top>a?e.top-a:Math.max(0,a-e.bottom)}function tl(a,e){return a.top<e.bottom-1&&a.bottom>e.top+1}function fo(a,e){return e<a.top?{top:e,left:a.left,right:a.right,bottom:a.bottom}:a}function uo(a,e){return e>a.bottom?{top:a.top,left:a.left,right:a.right,bottom:e}:a}function il(a,e,t){let n,l,s,o,r=!1,d,h,f,c;for(let b=a.firstChild;b;b=b.nextSibling){let y=Zt(b);for(let w=0;w<y.length;w++){let v=y[w];l&&tl(l,v)&&(v=fo(uo(v,l.bottom),l.top));let k=Ic(e,v),O=Dc(t,v);if(k==0&&O==0)return b.nodeType==3?po(b,e,t):il(b,e,t);if(!n||o>O||o==O&&s>k){n=b,l=v,s=k,o=O;let g=O?t<v.top?-1:1:k?e<v.left?-1:1:0;r=!g||(g>0?w<y.length-1:w>0)}k==0?t>v.bottom&&(!f||f.bottom<v.bottom)?(d=b,f=v):t<v.top&&(!c||c.top>v.top)&&(h=b,c=v):f&&tl(f,v)?f=uo(f,v.bottom):c&&tl(c,v)&&(c=fo(c,v.top))}}if(f&&f.bottom>=t?(n=d,l=f):c&&c.top<=t&&(n=h,l=c),!n)return{node:a,offset:0};let p=Math.max(l.left,Math.min(l.right,e));if(n.nodeType==3)return po(n,p,t);if(r&&n.contentEditable!="false")return il(n,p,t);let m=Array.prototype.indexOf.call(a.childNodes,n)+(e>=(l.left+l.right)/2?1:0);return{node:a,offset:m}}function po(a,e,t){let n=a.nodeValue.length,l=-1,s=1e9,o=0;for(let r=0;r<n;r++){let d=yt(a,r,r+1).getClientRects();for(let h=0;h<d.length;h++){let f=d[h];if(f.top==f.bottom)continue;o||(o=e-f.left);let c=(f.top>t?f.top-t:t-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&c<s){let p=e>=(f.left+f.right)/2,m=p;if((W.chrome||W.gecko)&&yt(a,r).getBoundingClientRect().left==f.right&&(m=!p),c<=0)return{node:a,offset:r+(m?1:0)};l=r+(m?1:0),s=c}}}return{node:a,offset:l>-1?l:o>0?a.nodeValue.length:0}}function mo(a,e,t,n=-1){var l,s;let o=a.contentDOM.getBoundingClientRect(),r=o.top+a.viewState.paddingTop,d,{docHeight:h}=a.viewState,{x:f,y:c}=e,p=c-r;if(p<0)return 0;if(p>h)return a.state.doc.length;for(let g=a.viewState.heightOracle.textHeight/2,u=!1;d=a.elementAtHeight(p),d.type!=ze.Text;)for(;p=n>0?d.bottom+g:d.top-g,!(p>=0&&p<=h);){if(u)return t?null:0;u=!0,n=-n}c=r+p;let m=d.from;if(m<a.viewport.from)return a.viewport.from==0?0:t?null:go(a,o,d,f,c);if(m>a.viewport.to)return a.viewport.to==a.state.doc.length?a.state.doc.length:t?null:go(a,o,d,f,c);let b=a.dom.ownerDocument,y=a.root.elementFromPoint?a.root:b,w=y.elementFromPoint(f,c);w&&!a.contentDOM.contains(w)&&(w=null),w||(f=Math.max(o.left+1,Math.min(o.right-1,f)),w=y.elementFromPoint(f,c),w&&!a.contentDOM.contains(w)&&(w=null));let v,k=-1;if(w&&((l=a.docView.nearest(w))===null||l===void 0?void 0:l.isEditable)!=!1){if(b.caretPositionFromPoint){let g=b.caretPositionFromPoint(f,c);g&&({offsetNode:v,offset:k}=g)}else if(b.caretRangeFromPoint){let g=b.caretRangeFromPoint(f,c);g&&({startContainer:v,startOffset:k}=g,(!a.contentDOM.contains(v)||W.safari&&Pc(v,k,f)||W.chrome&&Fc(v,k,f))&&(v=void 0))}}if(!v||!a.docView.dom.contains(v)){let g=fe.find(a.docView,m);if(!g)return p>d.top+d.height/2?d.to:d.from;({node:v,offset:k}=il(g.dom,f,c))}let O=a.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let g=O.dom.getBoundingClientRect();return e.y<g.top||e.y<=g.bottom&&e.x<=(g.left+g.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,k)+O.posAtStart}function go(a,e,t,n,l){let s=Math.round((n-e.left)*a.defaultCharacterWidth);if(a.lineWrapping&&t.height>a.defaultLineHeight*1.5){let r=a.viewState.heightOracle.textHeight,d=Math.floor((l-t.top-(a.defaultLineHeight-r)*.5)/r);s+=d*a.viewState.heightOracle.lineLength}let o=a.state.sliceDoc(t.from,t.to);return t.from+tc(o,s,a.state.tabSize)}function Pc(a,e,t){let n;if(a.nodeType!=3||e!=(n=a.nodeValue.length))return!1;for(let l=a.nextSibling;l;l=l.nextSibling)if(l.nodeType!=1||l.nodeName!="BR")return!1;return yt(a,n-1,n).getBoundingClientRect().left>t}function Fc(a,e,t){if(e!=0)return!1;for(let l=a;;){let s=l.parentNode;if(!s||s.nodeType!=1||s.firstChild!=l)return!1;if(s.classList.contains("cm-line"))break;l=s}let n=a.nodeType==1?a.getBoundingClientRect():yt(a,0,Math.max(a.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function $c(a,e){let t=a.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==ze.Text))return n}return t}function Rc(a,e,t,n){let l=$c(a,e.head),s=!n||l.type!=ze.Text||!(a.lineWrapping||l.widgetLineBreaks)?null:a.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(s){let o=a.dom.getBoundingClientRect(),r=a.textDirectionAt(l.from),d=a.posAtCoords({x:t==(r==be.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(d!=null)return H.cursor(d,t?-1:1)}return H.cursor(t?l.to:l.from,t?-1:1)}function ko(a,e,t,n){let l=a.state.doc.lineAt(e.head),s=a.bidiSpans(l),o=a.textDirectionAt(l.from);for(let r=e,d=null;;){let h=vc(l,s,o,r,t),f=Ks;if(!h){if(l.number==(t?a.state.doc.lines:1))return r;f=`
8
+ `,l=a.state.doc.line(l.number+(t?1:-1)),s=a.bidiSpans(l),h=a.visualLineSide(l,!t)}if(d){if(!d(f))return r}else{if(!n)return h;d=n(f)}r=h}}function Lc(a,e,t){let n=a.state.charCategorizer(e),l=n(t);return s=>{let o=n(s);return l==Xe.Space&&(l=o),l==o}}function jc(a,e,t,n){let l=e.head,s=t?1:-1;if(l==(t?a.state.doc.length:0))return H.cursor(l,e.assoc);let o=e.goalColumn,r,d=a.contentDOM.getBoundingClientRect(),h=a.coordsAtPos(l,e.assoc||-1),f=a.documentTop;if(h)o==null&&(o=h.left-d.left),r=s<0?h.top:h.bottom;else{let m=a.viewState.lineBlockAt(l);o==null&&(o=Math.min(d.right-d.left,a.defaultCharacterWidth*(l-m.from))),r=(s<0?m.top:m.bottom)+f}let c=d.left+o,p=n??a.viewState.heightOracle.textHeight>>1;for(let m=0;;m+=10){let b=r+(p+m)*s,y=mo(a,{x:c,y:b},!1,s);if(b<d.top||b>d.bottom||(s<0?y<l:y>l)){let w=a.docView.coordsForChar(y),v=!w||b<w.top?-1:1;return H.cursor(y,v,void 0,o)}}}function Ri(a,e,t){for(;;){let n=0;for(let l of a)l.between(e-1,e+1,(s,o,r)=>{if(e>s&&e<o){let d=n||t||(e-s<o-e?-1:1);e=d<0?s:o,n=d}});if(!n)return e}}function nl(a,e,t){let n=Ri(a.state.facet(el).map(l=>l(a)),t.from,e.head>t.from?-1:1);return n==t.from?t:H.cursor(n,n<t.from?1:-1)}const ai="￿";class zc{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ai}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let l=e;;){this.findPointBefore(n,l);let s=this.text.length;this.readNode(l);let o=l.nextSibling;if(o==t)break;let r=oe.get(l),d=oe.get(o);(r&&d?r.breakAfter:(r?r.breakAfter:Ai(l))||Ai(o)&&(l.nodeName!="BR"||l.cmIgnore)&&this.text.length>s)&&this.lineBreak(),l=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,r;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(r=l.exec(t))&&(s=r.index,o=r[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let d of this.points)d.node==e&&d.pos>this.text.length&&(d.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=oe.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let l=n.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(qc(e,n.node,n.offset)?t:0))}}function qc(a,e,t){for(;;){if(!e||t<Je(e))return!1;if(e==a)return!0;t=bt(e)+1,e=e.parentNode}}class bo{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Uc{constructor(e,t,n,l){this.typeOver=l,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let r=s||o?[]:Kc(e),d=new zc(r,e.state);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=Qc(r,this.bounds.from)}else{let r=e.observer.selectionRange,d=s&&s.node==r.focusNode&&s.offset==r.focusOffset||!In(e.contentDOM,r.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(r.focusNode,r.focusOffset),h=o&&o.node==r.anchorNode&&o.offset==r.anchorOffset||!In(e.contentDOM,r.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(r.anchorNode,r.anchorOffset),f=e.viewport;if((W.ios||W.chrome)&&e.state.selection.main.empty&&d!=h&&(f.from>0||f.to<e.state.doc.length)){let c=Math.min(d,h),p=Math.max(d,h),m=f.from-c,b=f.to-p;(m==0||m==1||c==0)&&(b==0||b==-1||p==e.state.doc.length)&&(d=0,h=e.state.doc.length)}this.newSel=H.single(h,d)}}}function yo(a,e){let t,{newSel:n}=e,l=a.state.selection.main,s=a.inputState.lastKeyTime>Date.now()-100?a.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:r}=e.bounds,d=l.from,h=null;(s===8||W.android&&e.text.length<r-o)&&(d=l.to,h="end");let f=Hc(a.state.doc.sliceString(o,r,ai),e.text,d-o,h);f&&(W.chrome&&s==13&&f.toB==f.from+2&&e.text.slice(f.from,f.toB)==ai+ai&&f.toB--,t={from:o+f.from,to:o+f.toA,insert:ie.of(e.text.slice(f.from,f.toB).split(ai))})}else n&&(!a.hasFocus&&a.state.facet(dt)||n.main.eq(l))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!l.empty&&n&&n.main.empty?t={from:l.from,to:l.to,insert:a.state.doc.slice(l.from,l.to)}:t&&t.from>=l.from&&t.to<=l.to&&(t.from!=l.from||t.to!=l.to)&&l.to-l.from-(t.to-t.from)<=4?t={from:l.from,to:l.to,insert:a.state.doc.slice(l.from,t.from).append(t.insert).append(a.state.doc.slice(t.to,l.to))}:(W.mac||W.android)&&t&&t.from==t.to&&t.from==l.head-1&&/^\. ?$/.test(t.insert.toString())&&a.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=H.single(n.main.anchor-1,n.main.head-1)),t={from:l.from,to:l.to,insert:ie.of([" "])}):W.chrome&&t&&t.from==t.to&&t.from==l.head&&t.insert.toString()==`
9
+ `&&a.lineWrapping&&(n&&(n=H.single(n.main.anchor-1,n.main.head-1)),t={from:l.from,to:l.to,insert:ie.of([" "])}),t)return ll(a,t,n,s);if(n&&!n.main.eq(l)){let o=!1,r="select";return a.inputState.lastSelectionTime>Date.now()-50&&(a.inputState.lastSelectionOrigin=="select"&&(o=!0),r=a.inputState.lastSelectionOrigin),a.dispatch({selection:n,scrollIntoView:o,userEvent:r}),!0}else return!1}function ll(a,e,t,n=-1){if(W.ios&&a.inputState.flushIOSKey(e))return!0;let l=a.state.selection.main;if(W.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&a.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Mt(a.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>l.head)&&Mt(a.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&Mt(a.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();a.inputState.composing>=0&&a.inputState.composing++;let o,r=()=>o||(o=Wc(a,e,t));return a.state.facet(Js).some(d=>d(a,e.from,e.to,s,r))||a.dispatch(r()),!0}function Wc(a,e,t){let n,l=a.state,s=l.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&a.inputState.composing<0){let r=s.from<e.from?l.sliceDoc(s.from,e.from):"",d=s.to>e.to?l.sliceDoc(e.to,s.to):"";n=l.replaceSelection(a.state.toText(r+e.insert.sliceString(0,void 0,a.state.lineBreak)+d))}else{let r=l.changes(e),d=t&&t.main.to<=r.newLength?t.main:void 0;if(l.selection.ranges.length>1&&a.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=a.state.sliceDoc(e.from,e.to),f,c=t&&ho(a,t.main.head);if(c){let b=e.insert.length-(e.to-e.from);f={from:c.from,to:c.to-b}}else f=a.state.doc.lineAt(s.head);let p=s.to-e.to,m=s.to-s.from;n=l.changeByRange(b=>{if(b.from==s.from&&b.to==s.to)return{changes:r,range:d||b.map(r)};let y=b.to-p,w=y-h.length;if(b.to-b.from!=m||a.state.sliceDoc(w,y)!=h||b.to>=f.from&&b.from<=f.to)return{range:b};let v=l.changes({from:w,to:y,insert:e.insert}),k=b.to-s.to;return{changes:v,range:d?H.range(Math.max(0,d.anchor+k),Math.max(0,d.head+k)):b.map(v)}})}else n={changes:r,selection:d&&l.selection.replaceRange(d)}}let o="input.type";return(a.composing||a.inputState.compositionPendingChange&&a.inputState.compositionEndedAt>Date.now()-50)&&(a.inputState.compositionPendingChange=!1,o+=".compose",a.inputState.compositionFirstChange&&(o+=".start",a.inputState.compositionFirstChange=!1)),l.update(n,{userEvent:o,scrollIntoView:!0})}function Hc(a,e,t,n){let l=Math.min(a.length,e.length),s=0;for(;s<l&&a.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==l&&a.length==e.length)return null;let o=a.length,r=e.length;for(;o>0&&r>0&&a.charCodeAt(o-1)==e.charCodeAt(r-1);)o--,r--;if(n=="end"){let d=Math.max(0,s-Math.min(o,r));t-=o+d-s}if(o<s&&a.length<e.length){let d=t<=s&&t>=o?s-t:0;s-=d,r=s+(r-o),o=s}else if(r<s){let d=t<=s&&t>=r?s-t:0;s-=d,o=s+(o-r),r=s}return{from:s,toA:o,toB:r}}function Kc(a){let e=[];if(a.root.activeElement!=a.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:l,focusOffset:s}=a.observer.selectionRange;return t&&(e.push(new bo(t,n)),(l!=t||s!=n)&&e.push(new bo(l,s))),e}function Qc(a,e){if(a.length==0)return null;let t=a[0].pos,n=a.length==2?a[1].pos:t;return t>-1&&n>-1?H.single(t+e,n+e):null}class Gc{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,W.safari&&e.contentDOM.addEventListener("input",()=>null),W.gecko&&fh(e.contentDOM.ownerDocument)}handleEvent(e){!lh(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let l of n.observers)l(this.view,t);for(let l of n.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Yc(e),n=this.handlers,l=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,r=n[s];r&&o!=!r.handlers.length&&(l.removeEventListener(s,this.handleEvent),r=null),r||l.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&l.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Jc.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),W.android&&W.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return W.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=xo.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Xc.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Mt(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:W.safari&&!W.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function wo(a,e){return(t,n)=>{try{return e.call(a,n,t)}catch(l){Ue(t.state,l)}}}function Yc(a){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of a){let l=n.spec;if(l&&l.domEventHandlers)for(let s in l.domEventHandlers){let o=l.domEventHandlers[s];o&&t(s).handlers.push(wo(n.value,o))}if(l&&l.domEventObservers)for(let s in l.domEventObservers){let o=l.domEventObservers[s];o&&t(s).observers.push(wo(n.value,o))}}for(let n in Pe)t(n).handlers.push(Pe[n]);for(let n in Ee)t(n).observers.push(Ee[n]);return e}const xo=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Xc="dthko",Jc=[16,17,18,20,91,92,224,225],Li=6;function ji(a){return Math.max(0,a)*.7+8}function Zc(a,e){return Math.max(Math.abs(a.clientX-e.clientX),Math.abs(a.clientY-e.clientY))}class eh{constructor(e,t,n,l){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=oc(e.contentDOM),this.atoms=e.state.facet(el).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(se.allowMultipleSelections)&&th(e,t),this.dragging=nh(e,t)&&Mo(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Zc(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,l=0,s=0,o=this.view.win.innerWidth,r=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:r}=this.scrollParents.y.getBoundingClientRect());let d=ro(this.view);e.clientX-d.left<=l+Li?t=-ji(l-e.clientX):e.clientX+d.right>=o-Li&&(t=ji(e.clientX-o)),e.clientY-d.top<=s+Li?n=-ji(s-e.clientY):e.clientY+d.bottom>=r-Li&&(n=ji(e.clientY-r)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let l=e.ranges[n],s=null;if(l.empty){let o=Ri(this.atoms,l.from,0);o!=l.from&&(s=H.cursor(o,-1))}else{let o=Ri(this.atoms,l.from,-1),r=Ri(this.atoms,l.to,1);(o!=l.from||r!=l.to)&&(s=H.range(l.from==l.anchor?o:r,l.from==l.head?o:r))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?H.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function th(a,e){let t=a.state.facet(Qs);return t.length?t[0](e):W.mac?e.metaKey:e.ctrlKey}function ih(a,e){let t=a.state.facet(Gs);return t.length?t[0](e):W.mac?!e.altKey:!e.ctrlKey}function nh(a,e){let{main:t}=a.state.selection;if(t.empty)return!1;let n=Jt(a.root);if(!n||n.rangeCount==0)return!0;let l=n.getRangeAt(0).getClientRects();for(let s=0;s<l.length;s++){let o=l[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function lh(a,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=a.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=oe.get(t))&&n.ignoreEvent(e))return!1;return!0}const Pe=Object.create(null),Ee=Object.create(null),vo=W.ie&&W.ie_version<15||W.ios&&W.webkit_version<604;function sh(a){let e=a.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{a.focus(),t.remove(),Co(a,t.value)},50)}function zi(a,e,t){for(let n of a.facet(e))t=n(t,a);return t}function Co(a,e){e=zi(a.state,Yn,e);let{state:t}=a,n,l=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(sl!=null&&t.selection.ranges.every(d=>d.empty)&&sl==s.toString()){let d=-1;n=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==d)return{range:h};d=f.from;let c=t.toText((o?s.line(l++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:H.cursor(h.from+c.length)}})}else o?n=t.changeByRange(d=>{let h=s.line(l++);return{changes:{from:d.from,to:d.to,insert:h.text},range:H.cursor(d.from+h.length)}}):n=t.replaceSelection(s);a.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Ee.scroll=a=>{a.inputState.lastScrollTop=a.scrollDOM.scrollTop,a.inputState.lastScrollLeft=a.scrollDOM.scrollLeft},Pe.keydown=(a,e)=>(a.inputState.setSelectionOrigin("select"),e.keyCode==27&&a.inputState.tabFocusMode!=0&&(a.inputState.tabFocusMode=Date.now()+2e3),!1),Ee.touchstart=(a,e)=>{a.inputState.lastTouchTime=Date.now(),a.inputState.setSelectionOrigin("select.pointer")},Ee.touchmove=a=>{a.inputState.setSelectionOrigin("select.pointer")},Pe.mousedown=(a,e)=>{if(a.observer.flush(),a.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of a.state.facet(Ys))if(t=n(a,e),t)break;if(!t&&e.button==0&&(t=rh(a,e)),t){let n=!a.hasFocus;a.inputState.startMouseSelection(new eh(a,e,t,n)),n&&a.observer.ignore(()=>{Cs(a.contentDOM);let s=a.root.activeElement;s&&!s.contains(a.contentDOM)&&s.blur()});let l=a.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}return!1};function So(a,e,t,n){if(n==1)return H.cursor(e,t);if(n==2)return Ec(a.state,e,t);{let l=fe.find(a.docView,e),s=a.state.doc.lineAt(l?l.posAtEnd:e),o=l?l.posAtStart:s.from,r=l?l.posAtEnd:s.to;return r<a.state.doc.length&&r==s.to&&r++,H.range(o,r)}}let No=(a,e,t)=>e>=t.top&&e<=t.bottom&&a>=t.left&&a<=t.right;function oh(a,e,t,n){let l=fe.find(a.docView,e);if(!l)return 1;let s=e-l.posAtStart;if(s==0)return 1;if(s==l.length)return-1;let o=l.coordsAt(s,-1);if(o&&No(t,n,o))return-1;let r=l.coordsAt(s,1);return r&&No(t,n,r)?1:o&&o.bottom>=n?-1:1}function Bo(a,e){let t=a.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:oh(a,t,e.clientX,e.clientY)}}const ah=W.ie&&W.ie_version<=11;let Oo=null,Vo=0,_o=0;function Mo(a){if(!ah)return a.detail;let e=Oo,t=_o;return Oo=a,_o=Date.now(),Vo=!e||t>Date.now()-400&&Math.abs(e.clientX-a.clientX)<2&&Math.abs(e.clientY-a.clientY)<2?(Vo+1)%3:1}function rh(a,e){let t=Bo(a,e),n=Mo(e),l=a.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),l=l.map(s.changes))},get(s,o,r){let d=Bo(a,s),h,f=So(a,d.pos,d.bias,n);if(t.pos!=d.pos&&!o){let c=So(a,t.pos,t.bias,n),p=Math.min(c.from,f.from),m=Math.max(c.to,f.to);f=p<f.from?H.range(p,m):H.range(m,p)}return o?l.replaceRange(l.main.extend(f.from,f.to)):r&&n==1&&l.ranges.length>1&&(h=dh(l,d.pos))?h:r?l.addRange(f):H.create([f])}}}function dh(a,e){for(let t=0;t<a.ranges.length;t++){let{from:n,to:l}=a.ranges[t];if(n<=e&&l>=e)return H.create(a.ranges.slice(0,t).concat(a.ranges.slice(t+1)),a.mainIndex==t?0:a.mainIndex-(a.mainIndex>t?1:0))}return null}Pe.dragstart=(a,e)=>{let{selection:{main:t}}=a.state;if(e.target.draggable){let l=a.docView.nearest(e.target);if(l&&l.isWidget){let s=l.posAtStart,o=s+l.length;(s>=t.to||o<=t.from)&&(t=H.range(s,o))}}let{inputState:n}=a;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",zi(a.state,Xn,a.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Pe.dragend=a=>(a.inputState.draggedContent=null,!1);function To(a,e,t,n){if(t=zi(a.state,Yn,t),!t)return;let l=a.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=a.inputState,o=n&&s&&ih(a,e)?{from:s.from,to:s.to}:null,r={from:l,insert:t},d=a.state.changes(o?[o,r]:r);a.focus(),a.dispatch({changes:d,selection:{anchor:d.mapPos(l,-1),head:d.mapPos(l,1)},userEvent:o?"move.drop":"input.drop"}),a.inputState.draggedContent=null}Pe.drop=(a,e)=>{if(!e.dataTransfer)return!1;if(a.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),l=0,s=()=>{++l==t.length&&To(a,e,n.filter(o=>o!=null).join(a.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let r=new FileReader;r.onerror=s,r.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(r.result)||(n[o]=r.result),s()},r.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return To(a,e,n,!0),!0}return!1},Pe.paste=(a,e)=>{if(a.state.readOnly)return!0;a.observer.flush();let t=vo?null:e.clipboardData;return t?(Co(a,t.getData("text/plain")||t.getData("text/uri-list")),!0):(sh(a),!1)};function ch(a,e){let t=a.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),a.focus()},50)}function hh(a){let e=[],t=[],n=!1;for(let l of a.selection.ranges)l.empty||(e.push(a.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:s}of a.selection.ranges){let o=a.doc.lineAt(s);o.number>l&&(e.push(o.text),t.push({from:o.from,to:Math.min(a.doc.length,o.to+1)})),l=o.number}n=!0}return{text:zi(a,Xn,e.join(a.lineBreak)),ranges:t,linewise:n}}let sl=null;Pe.copy=Pe.cut=(a,e)=>{let{text:t,ranges:n,linewise:l}=hh(a.state);if(!t&&!l)return!1;sl=l?t:null,e.type=="cut"&&!a.state.readOnly&&a.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=vo?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(ch(a,t),!1)};const Ao=Nt.define();function Eo(a,e){let t=[];for(let n of a.facet(Zs)){let l=n(a,e);l&&t.push(l)}return t?a.update({effects:t,annotations:Ao.of(!0)}):null}function Io(a){setTimeout(()=>{let e=a.hasFocus;if(e!=a.inputState.notifiedFocused){let t=Eo(a.state,e);t?a.dispatch(t):a.update([])}},10)}Ee.focus=a=>{a.inputState.lastFocusTime=Date.now(),!a.scrollDOM.scrollTop&&(a.inputState.lastScrollTop||a.inputState.lastScrollLeft)&&(a.scrollDOM.scrollTop=a.inputState.lastScrollTop,a.scrollDOM.scrollLeft=a.inputState.lastScrollLeft),Io(a)},Ee.blur=a=>{a.observer.clearSelectionRange(),Io(a)},Ee.compositionstart=Ee.compositionupdate=a=>{a.observer.editContext||(a.inputState.compositionFirstChange==null&&(a.inputState.compositionFirstChange=!0),a.inputState.composing<0&&(a.inputState.composing=0))},Ee.compositionend=a=>{a.observer.editContext||(a.inputState.composing=-1,a.inputState.compositionEndedAt=Date.now(),a.inputState.compositionPendingKey=!0,a.inputState.compositionPendingChange=a.observer.pendingRecords().length>0,a.inputState.compositionFirstChange=null,W.chrome&&W.android?a.observer.flushSoon():a.inputState.compositionPendingChange?Promise.resolve().then(()=>a.observer.flush()):setTimeout(()=>{a.inputState.composing<0&&a.docView.hasComposition&&a.update([])},50))},Ee.contextmenu=a=>{a.inputState.lastContextMenu=Date.now()},Pe.beforeinput=(a,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&a.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let r=o[0],d=a.posAtDOM(r.startContainer,r.startOffset),h=a.posAtDOM(r.endContainer,r.endOffset);return ll(a,{from:d,to:h,insert:a.state.toText(s)},null),!0}}let l;if(W.chrome&&W.android&&(l=xo.find(s=>s.inputType==e.inputType))&&(a.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&a.hasFocus&&(a.contentDOM.blur(),a.focus())},100)}return W.ios&&e.inputType=="deleteContentForward"&&a.observer.flushSoon(),W.safari&&e.inputType=="insertText"&&a.inputState.composing>=0&&setTimeout(()=>Ee.compositionend(a,e),20),!1};const Do=new Set;function fh(a){Do.has(a)||(Do.add(a),a.addEventListener("copy",()=>{}),a.addEventListener("cut",()=>{}))}const Po=["pre-wrap","normal","pre-line","break-spaces"];let Dt=!1;function Fo(){Dt=!1}class uh{constructor(e){this.lineWrapping=e,this.doc=ie.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Po.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let l=e[n];l<0?n++:this.heightSamples[Math.floor(l*10)]||(t=!0,this.heightSamples[Math.floor(l*10)]=!0)}return t}refresh(e,t,n,l,s,o){let r=Po.indexOf(e)>-1,d=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=t,this.charWidth=n,this.textHeight=l,this.lineLength=s,d){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return d}}class ph{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class We{constructor(e,t,n,l,s){this.from=e,this.length=t,this.top=n,this.height=l,this._content=s}get type(){return typeof this._content=="number"?ze.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof at?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new We(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var de=function(a){return a[a.ByPos=0]="ByPos",a[a.ByHeight=1]="ByHeight",a[a.ByPosNoHeight=2]="ByPosNoHeight",a}(de||(de={}));const qi=.001;class Se{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>qi&&(Dt=!0),this.height=e)}replace(e,t,n){return Se.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,l){let s=this,o=n.doc;for(let r=l.length-1;r>=0;r--){let{fromA:d,toA:h,fromB:f,toB:c}=l[r],p=s.lineAt(d,de.ByPosNoHeight,n.setDoc(t),0,0),m=p.to>=h?p:s.lineAt(h,de.ByPosNoHeight,n,0,0);for(c+=m.to-h,h=m.to;r>0&&p.from<=l[r-1].toA;)d=l[r-1].fromA,f=l[r-1].fromB,r--,d<p.from&&(p=s.lineAt(d,de.ByPosNoHeight,n,0,0));f+=p.from-d,d=p.from;let b=ol.build(n.setDoc(o),e,f,c);s=Ui(s,s.replace(d,h,b))}return s.updateHeight(n,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,l=0,s=0;for(;;)if(t==n)if(l>s*2){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,l-=r.size}else if(s>l*2){let r=e[n];r.break?e.splice(n,1,r.left,null,r.right):e.splice(n,1,r.left,r.right),n+=2+r.break,s-=r.size}else break;else if(l<s){let r=e[t++];r&&(l+=r.size)}else{let r=e[--n];r&&(s+=r.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new mh(Se.of(e.slice(0,t)),o,Se.of(e.slice(n)))}}function Ui(a,e){return a==e?a:(a.constructor!=e.constructor&&(Dt=!0),e)}Se.prototype.size=1;class $o extends Se{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,l){return new We(l,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,l,s){return this.blockAt(0,n,l,s)}forEachLine(e,t,n,l,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,n,l,s))}updateHeight(e,t=0,n=!1,l){return l&&l.from<=t&&l.more&&this.setHeight(l.heights[l.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class _e extends $o{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,l){return new We(l,this.length,n,this.height,this.breaks)}replace(e,t,n){let l=n[0];return n.length==1&&(l instanceof _e||l instanceof ye&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof ye?l=new _e(l.length,this.height):l.height=this.height,this.outdated||(l.outdated=!1),l):Se.of(n)}updateHeight(e,t=0,n=!1,l){return l&&l.from<=t&&l.more?this.setHeight(l.heights[l.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ye extends Se{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,s=l-n+1,o,r=0;if(e.lineWrapping){let d=Math.min(this.height,e.lineHeight*s);o=d/s,this.length>s+1&&(r=(this.height-d)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:l,perLine:o,perChar:r}}blockAt(e,t,n,l){let{firstLine:s,lastLine:o,perLine:r,perChar:d}=this.heightMetrics(t,l);if(t.lineWrapping){let h=l+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),f=t.doc.lineAt(h),c=r+f.length*d,p=Math.max(n,e-c/2);return new We(f.from,f.length,p,c,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/r))),{from:f,length:c}=t.doc.line(s+h);return new We(f,c,n+r*h,r,0)}}lineAt(e,t,n,l,s){if(t==de.ByHeight)return this.blockAt(e,n,l,s);if(t==de.ByPosNoHeight){let{from:m,to:b}=n.doc.lineAt(e);return new We(m,b-m,0,0,0)}let{firstLine:o,perLine:r,perChar:d}=this.heightMetrics(n,s),h=n.doc.lineAt(e),f=r+h.length*d,c=h.number-o,p=l+r*c+d*(h.from-s-c);return new We(h.from,h.length,Math.max(l,Math.min(p,l+this.height-f)),f,0)}forEachLine(e,t,n,l,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:r,perLine:d,perChar:h}=this.heightMetrics(n,s);for(let f=e,c=l;f<=t;){let p=n.doc.lineAt(f);if(f==e){let b=p.number-r;c+=d*b+h*(e-s-b)}let m=d+h*p.length;o(new We(p.from,p.length,c,m,0)),c+=m,f=p.to+1}}replace(e,t,n){let l=this.length-t;if(l>0){let s=n[n.length-1];s instanceof ye?n[n.length-1]=new ye(s.length+l):n.push(null,new ye(l-1))}if(e>0){let s=n[0];s instanceof ye?n[0]=new ye(e+s.length):n.unshift(new ye(e-1),null)}return Se.of(n)}decomposeLeft(e,t){t.push(new ye(e-1),null)}decomposeRight(e,t){t.push(null,new ye(this.length-e-1))}updateHeight(e,t=0,n=!1,l){let s=t+this.length;if(l&&l.from<=t+this.length&&l.more){let o=[],r=Math.max(t,l.from),d=-1;for(l.from>t&&o.push(new ye(l.from-t-1).updateHeight(e,t));r<=s&&l.more;){let f=e.doc.lineAt(r).length;o.length&&o.push(null);let c=l.heights[l.index++];d==-1?d=c:Math.abs(c-d)>=qi&&(d=-2);let p=new _e(f,c);p.outdated=!1,o.push(p),r+=f+1}r<=s&&o.push(null,new ye(s-r).updateHeight(e,r));let h=Se.of(o);return(d<0||Math.abs(h.height-this.height)>=qi||Math.abs(d-this.heightMetrics(e,t).perLine)>=qi)&&(Dt=!0),Ui(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class mh extends Se{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,l){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,l):this.right.blockAt(e,t,s,l+this.left.length+this.break)}lineAt(e,t,n,l,s){let o=l+this.left.height,r=s+this.left.length+this.break,d=t==de.ByHeight?e<o:e<r,h=d?this.left.lineAt(e,t,n,l,s):this.right.lineAt(e,t,n,o,r);if(this.break||(d?h.to<r:h.from>r))return h;let f=t==de.ByPosNoHeight?de.ByPosNoHeight:de.ByPos;return d?h.join(this.right.lineAt(r,f,n,o,r)):this.left.lineAt(r,f,n,l,s).join(h)}forEachLine(e,t,n,l,s,o){let r=l+this.left.height,d=s+this.left.length+this.break;if(this.break)e<d&&this.left.forEachLine(e,t,n,l,s,o),t>=d&&this.right.forEachLine(e,t,n,r,d,o);else{let h=this.lineAt(d,de.ByPos,n,l,s);e<h.from&&this.left.forEachLine(e,h.from-1,n,l,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,r,d,o)}}replace(e,t,n){let l=this.left.length+this.break;if(t<l)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let r of n)s.push(r);if(e>0&&Ro(s,o-1),t<this.length){let r=s.length;this.decomposeRight(t,s),Ro(s,r)}return Se.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,l=n+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<l&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Se.of(this.break?[e,null,t]:[e,t]):(this.left=Ui(this.left,e),this.right=Ui(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,l){let{left:s,right:o}=this,r=t+s.length+this.break,d=null;return l&&l.from<=t+s.length&&l.more?d=s=s.updateHeight(e,t,n,l):s.updateHeight(e,t,n),l&&l.from<=r+o.length&&l.more?d=o=o.updateHeight(e,r,n,l):o.updateHeight(e,r,n),d?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ro(a,e){let t,n;a[e]==null&&(t=a[e-1])instanceof ye&&(n=a[e+1])instanceof ye&&a.splice(e-1,3,new ye(t.length+1+n.length))}const gh=5;class ol{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof _e?l.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new _e(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let l=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;l<0&&(l=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new $o(o,l,n)):(o||s||l>=gh)&&this.addLineDeco(l,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new ye(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _e)return e;let t=new _e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let l=this.ensureLine();l.length+=n,l.collapsed+=n,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let l of this.nodes)l instanceof _e&&l.updateHeight(this.oracle,n),n+=l?l.length:1;return this.nodes}static build(e,t,n,l){let s=new ol(n,e);return re.spans(t,n,l,s,0),s.finish(n)}}function kh(a,e,t){let n=new bh;return re.compare(a,e,t,n,0),n.changes}class bh{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,l){(e<t||n&&n.heightRelevant||l&&l.heightRelevant)&&qn(e,t,this.changes,5)}}function yh(a,e){let t=a.getBoundingClientRect(),n=a.ownerDocument,l=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(l.innerWidth,t.right),r=Math.max(0,t.top),d=Math.min(l.innerHeight,t.bottom);for(let h=a.parentNode;h&&h!=n.body;)if(h.nodeType==1){let f=h,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let p=f.getBoundingClientRect();s=Math.max(s,p.left),o=Math.min(o,p.right),r=Math.max(r,p.top),d=Math.min(h==a.parentNode?l.innerHeight:d,p.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:r-(t.top+e),bottom:Math.max(r,d)-(t.top+e)}}function wh(a,e){let t=a.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class al{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let l=e[n],s=t[n];if(l.from!=s.from||l.to!=s.to||l.size!=s.size)return!1}return!0}draw(e,t){return Ce.replace({widget:new xh(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class xh extends zn{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Lo{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=jo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=be.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Zn).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new uh(t),this.stateDeco=e.facet(si).filter(n=>typeof n!="function"),this.heightMap=Se.empty().applyChanges(this.stateDeco,ie.empty,this.heightOracle.setDoc(e.doc),[new Ae(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ce.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let l=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>l>=s&&l<=o)){let{from:s,to:o}=this.lineBlockAt(l);e.push(new Wi(s,o))}}return this.viewports=e.sort((n,l)=>n.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?jo:new rl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ri(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(si).filter(f=>typeof f!="function");let l=e.changedRanges,s=Ae.extendWithRanges(l,kh(n,this.stateDeco,e?e.changes:me.empty(this.state.doc.length))),o=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Fo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Dt)&&(e.flags|=2),r?(this.scrollAnchorPos=e.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let d=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<d.from||t.range.head>d.to)||!this.viewportIsAppropriate(d))&&(d=this.getViewport(0,t));let h=d.from!=this.viewport.from||d.to!=this.viewport.to;this.viewport=d,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Sc)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),l=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?be.RTL:be.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),r=t.getBoundingClientRect(),d=o||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let h=0,f=0;if(r.width&&r.height){let{scaleX:g,scaleY:u}=vs(t,r);(g>.005&&Math.abs(this.scaleX-g)>.005||u>.005&&Math.abs(this.scaleY-u)>.005)&&(this.scaleX=g,this.scaleY=u,h|=8,o=d=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,p=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=p)&&(this.paddingTop=c,this.paddingBottom=p,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(d=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=Bs(e.scrollDOM);let b=(this.printing?wh:yh)(t,this.paddingTop),y=b.top-this.pixelViewport.top,w=b.bottom-this.pixelViewport.bottom;this.pixelViewport=b;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(d=!0)),!this.inView&&!this.scrollTarget)return 0;let k=r.width;if((this.contentDOMWidth!=k||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=r.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),d){let g=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(g)&&(o=!0),o||l.lineWrapping&&Math.abs(k-this.contentDOMWidth)>l.charWidth){let{lineHeight:u,charWidth:N,textHeight:V}=e.docView.measureTextSize();o=u>0&&l.refresh(s,u,N,V,k/N,g),o&&(e.docView.minWidth=0,h|=8)}y>0&&w>0?f=Math.max(y,w):y<0&&w<0&&(f=Math.min(y,w)),Fo();for(let u of this.viewports){let N=u.from==this.viewport.from?g:e.docView.measureVisibleLineHeights(u);this.heightMap=(o?Se.empty().applyChanges(this.stateDeco,ie.empty,this.heightOracle,[new Ae(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,o,new ph(u.from,N))}Dt&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:r}=this,d=new Wi(l.lineAt(o-n*1e3,de.ByHeight,s,0,0).from,l.lineAt(r+(1-n)*1e3,de.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<d.from||h>d.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=l.lineAt(h,de.ByPos,s,0,0),p;t.y=="center"?p=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h<d.from?p=c.top:p=c.bottom-f,d=new Wi(l.lineAt(p-1e3/2,de.ByHeight,s,0,0).from,l.lineAt(p+f+1e3/2,de.ByHeight,s,0,0).to)}}return d}mapViewport(e,t){let n=t.mapPos(e.from,-1),l=t.mapPos(e.to,1);return new Wi(this.heightMap.lineAt(n,de.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(l,de.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:l}=this.heightMap.lineAt(e,de.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,de.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:r}=this;return(e==0||l<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=r+Math.max(10,Math.min(n,250)))&&l>o-2*1e3&&s<r+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let l of e)t.touchesRange(l.from,l.to)||n.push(new al(t.mapPos(l.from),t.mapPos(l.to),l.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,l=n?1e4:2e3,s=l>>1,o=l<<1;if(this.defaultTextDirection!=be.LTR&&!n)return[];let r=[],d=(f,c,p,m)=>{if(c-f<s)return;let b=this.state.selection.main,y=[b.from];b.empty||y.push(b.to);for(let v of y)if(v>f&&v<c){d(f,v-10,p,m),d(v+10,c,p,m);return}let w=Ch(e,v=>v.from>=p.from&&v.to<=p.to&&Math.abs(v.from-f)<s&&Math.abs(v.to-c)<s&&!y.some(k=>v.from<k&&v.to>k));if(!w){if(c<p.to&&t&&n&&t.visibleRanges.some(v=>v.from<=c&&v.to>=c)){let v=t.moveToLineBoundary(H.cursor(c),!1,!0).head;v>f&&(c=v)}w=new al(f,c,this.gapSize(p,f,c,m))}r.push(w)},h=f=>{if(f.length<o||f.type!=ze.Text)return;let c=vh(f.from,f.to,this.stateDeco);if(c.total<o)return;let p=this.scrollTarget?this.scrollTarget.range.head:null,m,b;if(n){let y=l/this.heightOracle.lineLength*this.heightOracle.lineHeight,w,v;if(p!=null){let k=Ki(c,p),O=((this.visibleBottom-this.visibleTop)/2+y)/f.height;w=k-O,v=k+O}else w=(this.visibleTop-f.top-y)/f.height,v=(this.visibleBottom-f.top+y)/f.height;m=Hi(c,w),b=Hi(c,v)}else{let y=c.total*this.heightOracle.charWidth,w=l*this.heightOracle.charWidth,v,k;if(p!=null){let O=Ki(c,p),g=((this.pixelViewport.right-this.pixelViewport.left)/2+w)/y;v=O-g,k=O+g}else v=(this.pixelViewport.left-w)/y,k=(this.pixelViewport.right+w)/y;m=Hi(c,v),b=Hi(c,k)}m>f.from&&d(f.from,m,f,c),b<f.to&&d(b,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return r}gapSize(e,t,n,l){let s=Ki(l,n)-Ki(l,t);return this.heightOracle.lineWrapping?e.height*s:l.total*this.heightOracle.charWidth*s}updateLineGaps(e){al.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ce.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];re.spans(e,this.viewport.from,this.viewport.to,{span(l,s){t.push({from:l,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((l,s)=>l.from!=t[s].from||l.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ri(this.heightMap.lineAt(e,de.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ri(this.heightMap.lineAt(this.scaler.fromDOM(e),de.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ri(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Wi{constructor(e,t){this.from=e,this.to=t}}function vh(a,e,t){let n=[],l=a,s=0;return re.spans(t,a,e,{span(){},point(o,r){o>l&&(n.push({from:l,to:o}),s+=o-l),l=r}},20),l<e&&(n.push({from:l,to:e}),s+=e-l),{total:s,ranges:n}}function Hi({total:a,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(a*t);for(let l=0;;l++){let{from:s,to:o}=e[l],r=o-s;if(n<=r)return s+n;n-=r}}function Ki(a,e){let t=0;for(let{from:n,to:l}of a.ranges){if(e<=l){t+=e-n;break}t+=l-n}return t/a.total}function Ch(a,e){for(let t of a)if(e(t))return t}const jo={toDOM(a){return a},fromDOM(a){return a},scale:1,eq(a){return a==this}};class rl{constructor(e,t,n){let l=0,s=0,o=0;this.viewports=n.map(({from:r,to:d})=>{let h=t.lineAt(r,de.ByPos,e,0,0).top,f=t.lineAt(d,de.ByPos,e,0,0).bottom;return l+=f-h,{from:r,to:d,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-l)/(t.height-l);for(let r of this.viewports)r.domTop=o+(r.top-s)*this.scale,o=r.domBottom=r.domTop+(r.bottom-r.top),s=r.bottom}toDOM(e){for(let t=0,n=0,l=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return l+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,l=s.domBottom}}fromDOM(e){for(let t=0,n=0,l=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-l)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,l=s.domBottom}}eq(e){return e instanceof rl?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function ri(a,e){if(e.scale==1)return a;let t=e.toDOM(a.top),n=e.toDOM(a.bottom);return new We(a.from,a.length,t,n-t,Array.isArray(a._content)?a._content.map(l=>ri(l,e)):a._content)}const Qi=Y.define({combine:a=>a.join(" ")}),dl=Y.define({combine:a=>a.indexOf(!0)>-1}),cl=ot.newName(),zo=ot.newName(),qo=ot.newName(),Uo={"&light":"."+zo,"&dark":"."+qo};function hl(a,e,t){return new ot(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,l=>{if(l=="&")return a;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):a+" "+n}})}const Sh=hl("."+cl,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Uo),Nh={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},fl=W.ie&&W.ie_version<=11;class Bh{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new ac,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(W.ie&&W.ie_version<=11||W.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(W.chrome&&W.chrome_version<126)&&(this.editContext=new Vh(e),e.state.facet(dt)&&(e.contentDOM.editContext=this.editContext.editContext)),fl&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,l=this.selectionRange;if(n.state.facet(dt)?n.root.activeElement!=this.dom:!Ti(n.dom,l))return;let s=l.anchorNode&&n.docView.nearest(l.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(W.ie&&W.ie_version<=11||W.android&&W.chrome)&&!n.state.selection.main.empty&&l.focusNode&&ei(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Jt(e.root);if(!t)return!1;let n=W.safari&&e.root.nodeType==11&&nc(this.dom.ownerDocument)==this.dom&&Oh(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let l=Ti(this.dom,n);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&dc(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),l&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Nh),fl&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),fl&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let l=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Mt(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,l=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(l=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:l}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),l=this.selectionChanged&&Ti(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Uc(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,l=yo(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),l}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=Wo(t,e.previousSibling||e.target.previousSibling,-1),l=Wo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(dt)!=e.state.facet(dt)&&(e.view.contentDOM.editContext=e.state.facet(dt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let l of this.scrollTargets)l.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Wo(a,e,t){for(;e;){let n=oe.get(e);if(n&&n.parent==a)return n;let l=e.parentNode;e=l!=a.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function Ho(a,e){let t=e.startContainer,n=e.startOffset,l=e.endContainer,s=e.endOffset,o=a.docView.domAtPos(a.state.selection.main.anchor);return ei(o.node,o.offset,l,s)&&([t,n,l,s]=[l,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:l,focusOffset:s}}function Oh(a,e){if(e.getComposedRanges){let l=e.getComposedRanges(a.root)[0];if(l)return Ho(a,l)}let t=null;function n(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return a.contentDOM.addEventListener("beforeinput",n,!0),a.dom.ownerDocument.execCommand("indent"),a.contentDOM.removeEventListener("beforeinput",n,!0),t?Ho(a,t):null}class Vh{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let{anchor:l}=e.state.selection.main,s={from:this.toEditorPos(n.updateRangeStart),to:this.toEditorPos(n.updateRangeEnd),insert:ie.of(n.text.split(`
10
+ `))};s.from==this.from&&l<this.from?s.from=l:s.to==this.to&&l>this.to&&(s.to=l),!(s.from==s.to&&!s.insert.length)&&(this.pendingContextChange=s,e.state.readOnly||ll(e,s,H.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=n=>{let l=[],s=null;for(let o=this.toEditorPos(n.rangeStart),r=this.toEditorPos(n.rangeEnd);o<r;o++){let d=e.coordsForChar(o);s=d&&new DOMRect(d.left,d.top,d.right-d.left,d.bottom-d.top)||s||new DOMRect,l.push(s)}t.updateCharacterBounds(n.rangeStart,l)},this.handlers.textformatupdate=n=>{let l=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,r=s.underlineThickness;if(o!="None"&&r!="None"){let d=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${r=="Thin"?1:2}px`;l.push(Ce.mark({attributes:{style:d}}).range(this.toEditorPos(s.rangeStart),this.toEditorPos(s.rangeEnd)))}}e.dispatch({effects:io.of(Ce.set(l))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let l=Jt(n.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,l=this.pendingContextChange;return e.changes.iterChanges((s,o,r,d,h)=>{if(n)return;let f=h.length-(o-s);if(l&&o>=l.to)if(l.from==s&&l.to==o&&l.insert.eq(h)){l=this.pendingContextChange=null,t+=f,this.to+=f;return}else l=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),l&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(n,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class le{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(l=>l.forEach(s=>n(s,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||rc(e.parent)||document,this.viewState=new Lo(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Fi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(li).map(l=>new Jn(l));for(let l of this.plugins)l.update(this);this.observer=new Bh(this),this.inputState=new Gc(this),this.inputState.ensureHandlers(this.plugins),this.docView=new co(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,l,s=this.state;for(let p of e){if(p.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=p.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,r=0,d=null;e.some(p=>p.annotation(Ao))?(this.inputState.notifiedFocused=o,r=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,d=Eo(s,o),d||(r=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(f=null)):this.observer.clear(),s.facet(se.phrases)!=this.state.facet(se.phrases))return this.setState(s);l=$i.create(this,s,e),l.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let p of e){if(c&&(c=c.map(p.changes)),p.scrollIntoView){let{main:m}=p.state.selection;c=new Et(m.empty?m:H.cursor(m.head,m.head>m.anchor?-1:1))}for(let m of p.effects)m.is(Fi)&&(c=m.value.clip(this.state))}this.viewState.update(l,c),this.bidiCache=Gi.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(oi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(p=>p.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(Qi)!=l.state.facet(Qi)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let p of this.state.facet(Gn))try{p(l)}catch(m){Ue(this.state,m,"update listener")}(d||f)&&Promise.resolve().then(()=>{d&&this.state==d.startState&&this.dispatch(d),f&&!yo(this,f)&&h.force&&Mt(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Lo(e),this.plugins=e.facet(li).map(n=>new Jn(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new co(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(li),n=e.state.facet(li);if(t!=n){let l=[];for(let s of n){let o=t.indexOf(s);if(o<0)l.push(new Jn(s));else{let r=this.plugins[o];r.mustUpdate=e,l.push(r)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l<this.plugins.length;l++)this.plugins[l].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Ue(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,l=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(l-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let r=0;;r++){if(o<0)if(Bs(n))s=-1,o=this.viewState.heightMap.height;else{let m=this.viewState.scrollAnchorAt(l);s=m.from,o=m.top}this.updateState=1;let d=this.viewState.measure(this);if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(r>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];d&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(m=>{try{return m.read(this)}catch(b){return Ue(this.state,b),Ko}}),c=$i.create(this,this.state,[]),p=!1;c.flags|=d,t?t.flags|=d:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),p=this.docView.update(c),p&&this.docViewUpdate());for(let m=0;m<h.length;m++)if(f[m]!=Ko)try{let b=h[m];b.write&&b.write(f[m],this)}catch(b){Ue(this.state,b)}if(p&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let b=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(b>1||b<-1){l=l+b,n.scrollTop=l/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let r of this.state.facet(Gn))r(t)}get themeClasses(){return cl+" "+(this.state.facet(dl)?qo:zo)+" "+this.state.facet(Qi)}updateAttrs(){let e=Qo(this,no,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(dt)?"true":"false",class:"cm-content",style:`${W.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Qo(this,Zn,t);let n=this.observer.ignore(()=>{let l=jn(this.contentDOM,this.contentAttrs,t),s=jn(this.dom,this.editorAttrs,e);return l||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let l of n.effects)if(l.is(le.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(oi);let e=this.state.facet(le.cspNonce);ot.mount(this.root,this.styleModules.concat(Sh).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return nl(this,e,ko(this,e,t,n))}moveByGroup(e,t){return nl(this,e,ko(this,e,t,n=>Lc(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),l=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return H.cursor(s.side(t,l)+e.from,s.forward(!t,l)?1:-1)}moveToLineBoundary(e,t,n=!0){return Rc(this,e,t,n)}moveVertically(e,t,n){return nl(this,e,jc(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),mo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let l=this.state.doc.lineAt(e),s=this.bidiSpans(l),o=s[rt.find(s,e-l.from,-1,t)];return Ei(n,o.dir==be.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(eo)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>_h)return Hs(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Ws(s.isolates,n=oo(this,e))))return s.order;n||(n=oo(this,e));let l=xc(e.text,t,n);return this.bidiCache.push(new Gi(e.from,e.to,t,n,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||W.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Cs(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fi.of(new Et(typeof e=="number"?H.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Fi.of(new Et(H.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return It.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return It.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=ot.newName(),l=[Qi.of(n),oi.of(hl(`.${n}`,e))];return t&&t.dark&&l.push(dl.of(!0)),l}static baseTheme(e){return qd.lowest(oi.of(hl("."+cl,e,Uo)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),l=n&&oe.get(n)||oe.get(e);return((t=l?.rootView)===null||t===void 0?void 0:t.view)||null}}le.styleModule=oi,le.inputHandler=Js,le.clipboardInputFilter=Yn,le.clipboardOutputFilter=Xn,le.scrollHandler=to,le.focusChangeEffect=Zs,le.perLineTextDirection=eo,le.exceptionSink=Xs,le.updateListener=Gn,le.editable=dt,le.mouseSelectionStyle=Ys,le.dragMovesSelection=Gs,le.clickAddsSelectionRange=Qs,le.decorations=si,le.outerDecorations=lo,le.atomicRanges=el,le.bidiIsolatedRanges=so,le.scrollMargins=ao,le.darkTheme=dl,le.cspNonce=Y.define({combine:a=>a.length?a[0]:""}),le.contentAttributes=Zn,le.editorAttributes=no,le.lineWrapping=le.contentAttributes.of({class:"cm-lineWrapping"}),le.announce=ue.define();const _h=4096,Ko={};class Gi{constructor(e,t,n,l,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=l,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],l=e.length?e[e.length-1].dir:be.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==l&&!t.touchesRange(o.from,o.to)&&n.push(new Gi(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function Qo(a,e,t){for(let n=a.state.facet(e),l=n.length-1;l>=0;l--){let s=n[l],o=typeof s=="function"?s(a):s;o&&Ln(o,t)}return t}const Mh=!W.ios,Go={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Mh&&(Go[".cm-line"].caretColor=Go[".cm-content"].caretColor="transparent !important");class Pt extends Ot{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Pt.prototype.elementClass="",Pt.prototype.toDOM=void 0,Pt.prototype.mapMode=Ve.TrackBefore,Pt.prototype.startSide=Pt.prototype.endSide=-1,Pt.prototype.point=!0;var ul;const Ft=new te;function Th(a){return Y.define({combine:a?e=>e.concat(a):void 0})}const Ah=new te;class Fe{constructor(e,t,n=[],l=""){this.data=e,this.name=l,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return pl(this)}}),this.parser=t,this.extension=[Rt.of(this),se.languageData.of((s,o,r)=>{let d=Yo(s,o,r),h=d.type.prop(Ft);if(!h)return[];let f=s.facet(h),c=d.type.prop(Ah);if(c){let p=d.resolve(o-d.from,r);for(let m of c)if(m.test(p,s)){let b=s.facet(m.facet);return m.type=="replace"?b:b.concat(f)}}return f})].concat(n)}isActiveAt(e,t,n=-1){return Yo(e,t,n).type.prop(Ft)==this.data}findRegions(e){let t=e.facet(Rt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],l=(s,o)=>{if(s.prop(Ft)==this.data){n.push({from:o,to:o+s.length});return}let r=s.prop(te.mounted);if(r){if(r.tree.prop(Ft)==this.data){if(r.overlay)for(let d of r.overlay)n.push({from:d.from+o,to:d.to+o});else n.push({from:o,to:o+s.length});return}else if(r.overlay){let d=n.length;if(l(r.tree,r.overlay[0].from+o),n.length>d)return}}for(let d=0;d<s.children.length;d++){let h=s.children[d];h instanceof he&&l(h,s.positions[d]+o)}};return l(pl(e),0),n}get allowsNesting(){return!0}}Fe.setState=ue.define();function Yo(a,e,t){let n=a.facet(Rt),l=pl(a).topNode;if(!n||n.allowsNesting)for(let s=l;s;s=s.enter(e,t,pe.ExcludeBuffers))s.type.isTop&&(l=s);return l}class Yi extends Fe{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Th(e.languageData);return new Yi(t,e.parser.configure({props:[Ft.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Yi(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function pl(a){let e=a.field(Fe.state,!1);return e?e.tree:he.empty}class Eh{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let di=null;class Xi{constructor(e,t,n=[],l,s,o,r,d){this.parser=e,this.state=t,this.fragments=n,this.tree=l,this.treeLen=s,this.viewport=o,this.skipped=r,this.scheduleOn=d,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Xi(e,t,[],he.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Eh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=he.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let l=this.parse.advance();if(l)if(this.fragments=this.withoutTempSkipped(ut.addTree(l,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=l,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ut.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=di;di=this;try{return e()}finally{di=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Xo(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:l,treeLen:s,viewport:o,skipped:r}=this;if(this.takeTree(),!e.empty){let d=[];if(e.iterChangedRanges((h,f,c,p)=>d.push({fromA:h,toA:f,fromB:c,toB:p})),n=ut.applyChanges(n,d),l=he.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){r=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);f<c&&r.push({from:f,to:c})}}}return new Xi(this.parser,t,n,l,s,o,r,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:l,to:s}=this.skipped[n];l<e.to&&s>e.from&&(this.fragments=Xo(this.fragments,l,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Dl{createParse(t,n,l){let s=l[0].from,o=l[l.length-1].to;return{parsedPos:s,advance(){let d=di;if(d){for(let h of l)d.tempSkipped.push(h);e&&(d.scheduleOn=d.scheduleOn?Promise.all([d.scheduleOn,e]):e)}return this.parsedPos=o,new he(Ne.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return di}}function Xo(a,e,t){return ut.applyChanges(a,[{fromA:e,toA:t,fromB:e,toB:t}])}class $t{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new $t(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Xi.create(e.facet(Rt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new $t(n)}}Fe.state=gt.define({create:$t.init,update(a,e){for(let t of e.effects)if(t.is(Fe.setState))return t.value;return e.startState.facet(Rt)!=e.state.facet(Rt)?$t.init(e.state):a.apply(e)}});let Jo=a=>{let e=setTimeout(()=>a(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Jo=a=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(a,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ml=typeof navigator<"u"&&(!((ul=navigator.scheduling)===null||ul===void 0)&&ul.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ih=It.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Fe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Fe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Jo(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:l}}=this.view,s=n.field(Fe.state);if(s.tree==s.context.tree&&s.context.isDone(l+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ml?Math.max(25,e.timeRemaining()-5):1e9),r=s.context.treeLen<l&&n.doc.length>l+1e3,d=s.context.work(()=>ml&&ml()||Date.now()>o,l+(r?0:1e5));this.chunkBudget-=Date.now()-t,(d||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Fe.setState.of(new $t(s.context))})),this.chunkBudget>0&&!(d&&!r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ue(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Rt=Y.define({combine(a){return a.length?a[0]:null},enables:a=>[Fe.state,Ih,le.contentAttributes.compute([a],e=>{let t=e.facet(a);return t&&t.name?{"data-language":t.name}:{}})]});class Dh{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Ph=new te;function Zo({except:a,units:e=1}={}){return t=>{let n=a&&a.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const Fh=new te;function $h(a){let e=a.firstChild,t=a.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?a.to:t.from}:null}class gl{constructor(e,t){this.specs=e;let n;function l(r){let d=ot.newName();return(n||(n=Object.create(null)))["."+d]=r,d}const s=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,o=t.scope;this.scope=o instanceof Fe?r=>r.prop(Ft)==o.data:o?r=>r==o:void 0,this.style=ql(e.map(r=>({tag:r.tag,class:r.class||l(Object.assign({},r,{tag:null}))})),{all:s}).style,this.module=n?new ot(n):null,this.themeType=t.themeType}static define(e,t){return new gl(e,t||{})}}z.meta,z.link,z.heading,z.emphasis,z.strong,z.strikethrough,z.keyword,z.atom,z.bool,z.url,z.contentSeparator,z.labelName,z.literal,z.inserted,z.string,z.deleted,z.regexp,z.escape,z.string,z.variableName,z.variableName,z.typeName,z.namespace,z.className,z.variableName,z.macroName,z.propertyName,z.comment,z.invalid;const Rh=Object.create(null),ea=[Ne.none],ta=[],ia=Object.create(null),Lh=Object.create(null);for(let[a,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Lh[a]=jh(Rh,e);function kl(a,e){ta.indexOf(a)>-1||(ta.push(a),console.warn(e))}function jh(a,e){let t=[];for(let r of e.split(" ")){let d=[];for(let h of r.split(".")){let f=a[h]||z[h];f?typeof f=="function"?d.length?d=d.map(f):kl(h,`Modifier ${h} used at start of tag`):d.length?kl(h,`Tag ${h} used as modifier`):d=Array.isArray(f)?f:[f]:kl(h,`Unknown highlighting tag ${h}`)}for(let h of d)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),l=n+" "+t.map(r=>r.id),s=ia[l];if(s)return s.id;let o=ia[l]=Ne.define({id:ea.length,name:n,props:[zl({[n]:t})]});return ea.push(o),o.id}be.RTL,be.LTR;const zh=Yi.define({name:"json",parser:Fd.configure({props:[Ph.add({Object:Zo({except:/^\s*\}/}),Array:Zo({except:/^\s*\]/})}),Fh.add({"Object Array":$h})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function qh(){return new Dh(zh)}const bl=[{name:"tel",title:"手机号",express:"^1[3-9]\\d{9}$",error:"手机号不正确"},{name:"email",title:"邮箱",express:"^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",error:"邮箱不正确"},{name:"idcard",title:"身份证号码",express:"(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)",error:"身份证号码不正确"}];function Uh(){const a=Ie();if(a.formRules?.length){const e={};bl.forEach(n=>{e[n.name]=n});const t=[...bl];return a.formRules.forEach(n=>{const l=e[n.name];l?Object.assign(l,n):t.push(l)}),t}return bl}const Wh={loadAdvances:Uh},Hh={class:"unione-props-setting data-field-setting"},Kh={key:0},Qh=["onClick"],Gh={class:"field-txt"},Yh=["onClick"],Xh={key:1,class:"field-txt"},Jh=["onClick"],Zh={key:0,class:"field-txt"},ef={key:3,class:"edit-field"},tf=["onClick"],nf=ne(i.defineComponent({__name:"dataFieldSetting",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=i.ref([qh()]),t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"30px",fixed:"left",align:"center",customRender:({index:g})=>g+1},{title:"字段名称",dataIndex:"name",key:"name",width:"70px",rowDrag:!0,resizable:!0,fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"90px",align:"center"},{title:"控件类型",dataIndex:"widget",key:"widget",width:"60px",align:"center"},{title:"验证规则",dataIndex:"rules",key:"rules",width:"60px",align:"center"},{title:"表单",dataIndex:"form",key:"form",width:"40px",align:"center"},{title:"详情",dataIndex:"view",key:"view",width:"40px",align:"center"},{title:"列表",dataIndex:"list",key:"list",width:"40px",align:"center"},{title:"排序",dataIndex:"sort",key:"sort",width:"40px",align:"center"},{title:"查询",dataIndex:"query",key:"query",width:"40px",align:"center"},{title:"转换器",dataIndex:"convertName",key:"convertName",width:"50px",align:"center"}]),n=i.useModel(a,"modelValue"),l={mounted:g=>g.focus()},s=i.ref({});function o(){const g=Object.keys(s.value);if(g.length)for(let u in g){const N=n.value.filter(V=>V.name==u);if(N&&N[0]){let V=s.value[u];Object.keys(V).forEach(C=>{C=="convertName"?(N[0].convert||(N[0].convert={}),N[0].convert.type=V[C]):N[0][C]=V[C]})}}s.value={}}function r(g,u){o();const N={};u=="convertName"?(g.convert||(g.convert={}),N[u]=g.convert?.type):N[u]=g[u]||"",s.value[g.name]=N}function d(g,u){{s.value={};return}}function h(g,u){switch(u){case"query":return g.configs?.query?.enable;case"form":return g.configs?.show?.form?.enable;case"view":return g.configs?.show?.view?.enable;case"list":return g.configs?.show?.list?.enable;case"sort":return g.configs?.sort?.enable}}function f(g,u){switch(u){case"query":g.configs=K.utils.obj.ext(g.configs,{query:{enable:!1}}),g.configs.query.enable=!g.configs.query.enable;break;case"form":g.configs=K.utils.obj.ext(g.configs,{show:{form:{enable:!1}}}),g.configs.show.form.enable=!g.configs.show.form.enable;break;case"view":g.configs=K.utils.obj.ext(g.configs,{show:{view:{enable:!1}}}),g.configs.show.view.enable=!g.configs.show.view.enable;break;case"list":g.configs=K.utils.obj.ext(g.configs,{show:{list:{enable:!1}}}),g.configs.show.list.enable=!g.configs.show.list.enable;break;case"sort":g.configs=K.utils.obj.ext(g.configs,{sort:{enable:!1}}),g.configs.sort.enable=!g.configs.sort.enable;break}console.log("record.configs",g.configs)}const c=i.ref({title:"列头设置",prop:"list",visible:!1,field:{},show:{},toSetting:()=>{c.value.visible=!1}});function p(g,u){switch(c.value.prop=u,c.value.field=g,g.configs||(g.configs={}),g.configs.show||(g.configs.show={}),u){case"query":g.configs.query||(g.configs.query={}),g.configs.query.types||(g.configs.query.types="EQ"),c.value.show=g.configs.query,c.value.title=`查询设置/${g.title}(${g.name})`;break;case"form":g.configs.show.form||(g.configs.show.form={}),c.value.show=g.configs.show.form,c.value.title=`表单设置/${g.title}(${g.name})`;break;case"view":g.configs.show.view||(g.configs.show.view={}),c.value.show=g.configs.show.view,c.value.title=`详情设置/${g.title}(${g.name})`;break;case"list":g.configs.show.list||(g.configs.show.list={}),c.value.show=g.configs.show.list,c.value.title=`列头设置/${g.title}(${g.name})`;break;case"sort":g.configs.sort||(g.configs.sort={}),c.value.show=g.configs.sort,c.value.title=`排序设置/${g.title}(${g.name})`;break}c.value.visible=!0}const m=i.ref({options:[{value:"keywords",label:"关键字"},{value:"equle",label:"精确"},{value:"like",label:"模糊"},{value:"like-right",label:"右模糊"},{value:"like-left",label:"左模糊"},{value:"range",label:"范围"}],showLabel:g=>{const u=m.value.options.filter(N=>N.value==g);return u[0]?u[0].label:g}}),b=i.ref({visible:!1,field:{},props:{},advances:Wh.loadAdvances(),showInfo:g=>{let u=0;if(g.configs?.rule){const N=g.configs.rule;N.advance&&u++,typeof N.rangeMin<"u"&&u++,typeof N.rangeMax<"u"&&u++,typeof N.regExpress<"u"&&u++}if(u>0)return"("+u+")"},toSetting:()=>{const g=b.value.props;b.value.field.configs=K.utils.obj.ext(b.value.field.configs,{rule:{...g}}),b.value.visible=!1,b.value.props={}}});function y(g){b.value.visible=!0,b.value.field=g,b.value.props=g.configs?.rule||{}}const w=i.ref({visible:!1,field:{},widget:{},widgets:[{value:"a-input",label:"文本框"},{value:"a-input-number",label:"数值框"},{value:"unione-check-box",label:"多选框"},{value:"unione-radio-box",label:"单选框"},{value:"unione-switch-box",label:"开关"},{value:"unione-select-box",label:"下拉框"},{value:"unione-tree-box",label:"下拉树"},{value:"a-date-picker",label:"日期框"},{value:"a-input-password",label:"密码框"},{value:"a-input-search",label:"搜索框"},{value:"a-upload",label:"文件框"},{value:"unione-avatar",label:"头像框",disabled:!0},{value:"unione-picture-card",label:"照片墙"},{value:"a-slider",label:"滑块"},{value:"a-textarea",label:"文本域"}],widgetName:g=>{const u=g.configs?.widget?.name,N=w.value.widgets.filter(V=>V.value==u);return N[0]?N[0].label:u},toSetting:(g,u)=>{g.configs||(g.configs={}),g.configs.widget||(g.configs.widget={}),g.configs.widget.name=u},toclose:()=>{w.value.visible=!1}});function v(g){w.value.field=g,g.configs=K.utils.obj.ext(g.configs,{widget:{props:{}}}),w.value.widget=g.configs.widget,w.value.visible=!0}const k=i.ref({visible:!1,field:{},convert:{},types:[{value:"dict",label:"字典"},{value:"option",label:"静态"},{value:"dbtable",label:"数据集"},{value:"remote",label:"远程接口"},{value:"local",label:"本地接口"}],optionColumn:[{title:"选项标题",dataIndex:"label"},{title:"选项值",dataIndex:"value"},{title:"操作",dataIndex:"action",width:"20%"}],getTypes:(g,u="--")=>k.value.types.filter(N=>N.value==g)[0]?.label||u,toAddOption:()=>{k.value.convert.options||(k.value.convert.options=[]),k.value.convert.options.push({label:"",value:""})},toDelOption:(g,u)=>{k.value.convert.options.splice(g,1)},toSetting:()=>{k.value.visible=!1}});function O(g){k.value.visible=!0,k.value.field=g,g.configs||(g.configs={}),g.configs.convert||(g.configs.convert={}),k.value.convert=g.configs.convert}return(g,u)=>{const N=i.resolveComponent("ToolOutlined"),V=i.resolveComponent("a-button"),C=i.resolveComponent("a-select"),x=i.resolveComponent("a-checkbox"),S=i.resolveComponent("a-table"),M=i.resolveComponent("a-switch"),T=i.resolveComponent("a-form-item"),E=i.resolveComponent("a-select-option"),I=i.resolveComponent("a-input-number"),L=i.resolveComponent("a-form"),A=i.resolveComponent("a-modal"),U=i.resolveComponent("a-input"),P=i.resolveComponent("unione-select-box"),G=i.resolveComponent("a-checkbox-group"),j=i.resolveComponent("unione-section");return i.openBlock(),i.createElementBlock("div",Hh,[i.createVNode(S,{columns:t.value,"data-source":n.value,bordered:"",scroll:{x:1e3},pagination:!0,"row-key":"name",size:"small"},{headerCell:i.withCtx(({column:B})=>[["widget","queryType","rules","convertName"].includes(B.key)?(i.openBlock(),i.createElementBlock("span",Kh,[i.createVNode(N),i.createTextVNode(" "+i.toDisplayString(B.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:B,text:F,record:_})=>[["rules"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",!b.value.showInfo(_)&&"empty"]),onClick:D=>y(_)},[i.createElementVNode("span",Gh,i.toDisplayString(b.value.showInfo(_)),1),b.value.showInfo(_)?(i.openBlock(),i.createBlock(V,{key:0,type:"link"},{default:i.withCtx(()=>u[50]||(u[50]=[i.createTextVNode("设置")])),_:1})):i.createCommentVNode("",!0)],10,Qh)):["widget"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[_.name]||!Object.keys(s.value[_.name]).includes(B.dataIndex))&&!F&&"empty"]),onClick:D=>r(_,B.dataIndex)},[s.value[_.name]&&Object.keys(s.value[_.name]).includes(B.dataIndex)?i.withDirectives((i.openBlock(),i.createBlock(C,{key:0,value:_.configs?.widget?.name,allowClear:!0,options:w.value.widgets,onChange:D=>w.value.toSetting(_,D),onBlur:u[0]||(u[0]=D=>d())},null,8,["value","options","onChange"])),[[l]]):(i.openBlock(),i.createElementBlock("span",Xh,i.toDisplayString(w.value.widgetName(_)),1)),i.createVNode(V,{type:"link",onClick:i.withModifiers(D=>v(_),["stop"])},{default:i.withCtx(()=>u[51]||(u[51]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])],10,Yh)):["convertName"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[_.name]||!Object.keys(s.value[_.name]).includes(B.dataIndex))&&!_.convert?.type&&"empty"]),onClick:D=>O(_)},[_.configs?.convert?.types?(i.openBlock(),i.createElementBlock("span",Zh,i.toDisplayString(k.value.getTypes(_.configs.convert.types)),1)):i.createCommentVNode("",!0)],10,Jh)):["query","form","view","list","sort"].includes(B.dataIndex)?(i.openBlock(),i.createElementBlock("div",ef,[i.createVNode(x,{checked:h(_,B.dataIndex),onClick:D=>f(_,B.dataIndex)},null,8,["checked","onClick"]),i.createVNode(V,{type:"link",onClick:D=>p(_,B.dataIndex)},{default:i.withCtx(()=>u[52]||(u[52]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])])):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(A,{visible:c.value.visible,"onUpdate:visible":u[14]||(u[14]=B=>c.value.visible=B),width:600,title:c.value.title,onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:c.value.show,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:i.normalizeClass(["field-setting-form","form-mix",c.value.prop])},{default:i.withCtx(()=>[i.createVNode(T,{label:"启用状态"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.enable,"onUpdate:checked":u[1]||(u[1]=B=>c.value.show.enable=B),checkedChildren:"启用",unCheckedChildren:"停用"},null,8,["checked"])]),_:1}),c.value.prop=="sort"?(i.openBlock(),i.createBlock(T,{key:0,label:"默认排序"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.defoult,"onUpdate:checked":u[2]||(u[2]=B=>c.value.show.defoult=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="sort"?(i.openBlock(),i.createBlock(T,{key:1,label:"排序方式"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.asc,"onUpdate:checked":u[3]||(u[3]=B=>c.value.show.asc=B),checkedChildren:"升序",unCheckedChildren:"降序"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"&&c.value.show.types=="ADVANCE"?(i.openBlock(),i.createBlock(T,{key:2,label:"高级查询"})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:3,label:"默认查询",tooltip:"开启后该字段加入关键字查询"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.defoult,"onUpdate:checked":u[4]||(u[4]=B=>c.value.show.defoult=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:4,label:"默认显示",tooltip:"开启后,在查询表单中默认显示该查询字段"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.show.visible,"onUpdate:checked":u[5]||(u[5]=B=>c.value.show.visible=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),c.value.prop=="query"?(i.openBlock(),i.createBlock(T,{key:5,label:"查询方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.types,"onUpdate:value":u[6]||(u[6]=B=>c.value.show.types=B)},{default:i.withCtx(()=>[i.createVNode(E,{key:"EQ",value:"EQ"},{default:i.withCtx(()=>u[53]||(u[53]=[i.createTextVNode("精确查询")])),_:1}),i.createVNode(E,{key:"LIKE",value:"LIKE"},{default:i.withCtx(()=>u[54]||(u[54]=[i.createTextVNode("模糊查询")])),_:1}),i.createVNode(E,{key:"LLIKE",value:"LLIKE"},{default:i.withCtx(()=>u[55]||(u[55]=[i.createTextVNode("左模糊")])),_:1}),i.createVNode(E,{key:"RLIKE",value:"RLIKE"},{default:i.withCtx(()=>u[56]||(u[56]=[i.createTextVNode("右模糊")])),_:1}),i.createVNode(E,{key:"RANGE",value:"RANGE"},{default:i.withCtx(()=>u[57]||(u[57]=[i.createTextVNode("范围查询")])),_:1}),i.createVNode(E,{key:"ADVANCE",value:"ADVANCE"},{default:i.withCtx(()=>u[58]||(u[58]=[i.createTextVNode("高级查询")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0),["query","sort"].includes(c.value.prop)?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(T,{key:6,label:"显示顺序",tooltip:"默认根据字段顺序显示,若需调整字段显示顺序,可以通过这里设置!"},{default:i.withCtx(()=>[i.createVNode(I,{value:c.value.show.index,"onUpdate:value":u[7]||(u[7]=B=>c.value.show.index=B)},null,8,["value"])]),_:1})),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:7,label:"显示宽度",tooltip:"字段显示宽度,0-24,设置成0,根据表单默认配置"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.width,"onUpdate:value":u[8]||(u[8]=B=>c.value.show.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:8,label:"显示宽度",tooltip:"字段显示宽度"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,value:c.value.show.width,"onUpdate:value":u[9]||(u[9]=B=>c.value.show.width=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:9,label:"标题宽度",tooltip:"表单title部分显示宽度,0-24"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.labelWidth,"onUpdate:value":u[10]||(u[10]=B=>c.value.show.labelWidth=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["form","view"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:10,label:"控件宽度",tooltip:"表单组件部分显示宽度,0-24"},{default:i.withCtx(()=>[i.createVNode(I,{min:0,max:24,value:c.value.show.valueWidth,"onUpdate:value":u[11]||(u[11]=B=>c.value.show.valueWidth=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:11,label:"固定位置"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.fixed,"onUpdate:value":u[12]||(u[12]=B=>c.value.show.fixed=B),allowClear:"",options:[{value:"left",label:"靠左"},{value:"right",label:"靠右"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["list"].includes(c.value.prop)?(i.openBlock(),i.createBlock(T,{key:12,label:"对齐方式"},{default:i.withCtx(()=>[i.createVNode(C,{value:c.value.show.align,"onUpdate:value":u[13]||(u[13]=B=>c.value.show.align=B),options:[{value:"left",label:"左对齐"},{value:"center",label:"居中"},{value:"right",label:"右对齐"}]},null,8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model","class"])]),_:1},8,["visible","title","onOk"]),i.createVNode(A,{visible:k.value.visible,"onUpdate:visible":u[33]||(u[33]=B=>k.value.visible=B),width:600,title:k.value.getTypes(k.value.convert.types,"转换")+"设置",onOk:k.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:k.value.convert,name:"basic","label-col":{span:5},"wrapper-col":{span:17},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(T,{label:"转换类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:k.value.convert.types,"onUpdate:value":u[15]||(u[15]=B=>k.value.convert.types=B),allowClear:!0,options:k.value.types},null,8,["value","options"])]),_:1}),["unione-select-box","unione-tree-box"].includes(k.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:0,label:"是否搜索"},{default:i.withCtx(()=>[i.createVNode(M,{checked:c.value.convert.search,"onUpdate:checked":u[16]||(u[16]=B=>c.value.convert.search=B),checkedChildren:"启用",unCheckedChildren:"停用"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="option"?(i.openBlock(),i.createBlock(T,{key:1,label:"选项设置"},{default:i.withCtx(()=>[i.createVNode(V,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:k.value.toAddOption},{default:i.withCtx(()=>u[59]||(u[59]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(S,{columns:k.value.optionColumn,"data-source":k.value.convert.options,size:"small"},{bodyCell:i.withCtx(({column:B,record:F,index:_})=>[B.dataIndex==="label"?(i.openBlock(),i.createBlock(U,{key:0,value:F.label,"onUpdate:value":D=>F.label=D,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),B.dataIndex==="value"?(i.openBlock(),i.createBlock(U,{key:1,value:F.value,"onUpdate:value":D=>F.value=D,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):i.createCommentVNode("",!0),B.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:2,onClick:D=>k.value.toDelOption(_,F)},"删除",8,tf)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])]),_:1})):i.createCommentVNode("",!0),["dbtable","remote"].includes(k.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:2,label:"数据源"},{default:i.withCtx(()=>[i.createVNode(P,{value:k.value.convert.dsId,"onUpdate:value":u[17]||(u[17]=B=>k.value.convert.dsId=B),convert:{types:"local",url:"/api/data/source/find",search:!0}},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:3,label:"table名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableName,"onUpdate:value":u[18]||(u[18]=B=>k.value.convert.tableName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:4,label:"table名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableName,"onUpdate:value":u[19]||(u[19]=B=>k.value.convert.tableName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"&&["unione-tree-box"].includes(k.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:5,label:"主键字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.idField,"onUpdate:value":u[20]||(u[20]=B=>k.value.convert.idField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"&&["unione-tree-box"].includes(k.value.field.widget?.name)?(i.openBlock(),i.createBlock(T,{key:6,label:"父级字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.pidField,"onUpdate:value":u[21]||(u[21]=B=>k.value.convert.pidField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:7,label:"value字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.valueField,"onUpdate:value":u[22]||(u[22]=B=>k.value.convert.valueField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:8,label:"label字段"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.labelField,"onUpdate:value":u[23]||(u[23]=B=>k.value.convert.labelField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:9,label:"扩展字段",tooltip:"默认只加载value,label字段,可以通过该属性加载其他更多字段,多个字段用逗号分隔"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableField,"onUpdate:value":u[24]||(u[24]=B=>k.value.convert.tableField=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:10,label:"数据过滤",tooltip:"支持数据条件过滤,eg:sex=1"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableWhere,"onUpdate:value":u[25]||(u[25]=B=>k.value.convert.tableWhere=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:11,label:"数据排序",tooltip:"设置数据进行排序方式,eg:age desc"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableOrder,"onUpdate:value":u[26]||(u[26]=B=>k.value.convert.tableOrder=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:12,label:"数据排序",tooltip:"设置数据进行排序方式,eg:age desc"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.tableOrder,"onUpdate:value":u[27]||(u[27]=B=>k.value.convert.tableOrder=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:13,label:"异步加载"},{default:i.withCtx(()=>[i.createVNode(M,{checked:k.value.convert.isAsync,"onUpdate:checked":u[28]||(u[28]=B=>k.value.convert.isAsync=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dbtable"?(i.openBlock(),i.createBlock(T,{key:14,label:"分页加载"},{default:i.withCtx(()=>[i.createVNode(M,{checked:k.value.convert.isPaging,"onUpdate:checked":u[29]||(u[29]=B=>k.value.convert.isPaging=B),checkedChildren:"是",unCheckedChildren:"否"},null,8,["checked"])]),_:1})):i.createCommentVNode("",!0),k.value.convert.types=="dict"?(i.openBlock(),i.createBlock(T,{key:15,label:"字典名称"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.dictName,"onUpdate:value":u[30]||(u[30]=B=>k.value.convert.dictName=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["local","remote"].includes(k.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:16,label:"接口地址",tooltip:"统一使用POST请求,json提交,标准结构:{body:{参数}}"},{default:i.withCtx(()=>[i.createVNode(U,{value:k.value.convert.url,"onUpdate:value":u[31]||(u[31]=B=>k.value.convert.url=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),["local","remote"].includes(k.value.convert.types)?(i.openBlock(),i.createBlock(T,{key:17,label:"接口参数",tooltip:"标准json对象/数组,直接使用该参数进行接口请求,请求确保结构和接口匹配!"},{default:i.withCtx(()=>[i.createVNode(i.unref(Lt.Codemirror),{modelValue:k.value.convert.params,"onUpdate:modelValue":u[32]||(u[32]=B=>k.value.convert.params=B),placeholder:"接口请求参数,eg:{sex:1}",style:{height:"250px"},autofocus:!0,"indent-with-tab":!0,tabSize:8,extensions:e.value,scrollbarStyle:null},null,8,["modelValue","extensions"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","title","onOk"]),i.createVNode(A,{visible:w.value.visible,"onUpdate:visible":u[40]||(u[40]=B=>w.value.visible=B),width:600,title:"控件设置",onOk:w.value.toclose},{default:i.withCtx(()=>[i.createVNode(L,{model:w.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(T,{label:"组件类型"},{default:i.withCtx(()=>[i.withDirectives(i.createVNode(C,{value:w.value.widget.name,"onUpdate:value":u[34]||(u[34]=B=>w.value.widget.name=B),allowClear:!0,options:w.value.widgets},null,8,["value","options"]),[[l]])]),_:1}),i.createVNode(T,{label:"输入提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.widget.placeholder,"onUpdate:value":u[35]||(u[35]=B=>w.value.widget.placeholder=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"帮助说明"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.widget.help,"onUpdate:value":u[36]||(u[36]=B=>w.value.widget.help=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"提示文本"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.widget.tooltip,"onUpdate:value":u[37]||(u[37]=B=>w.value.widget.tooltip=B)},null,8,["value"])]),_:1}),["a-date-picker"].includes(w.value.widget.name)?(i.openBlock(),i.createBlock(T,{key:0,label:"显示格式"},{default:i.withCtx(()=>[i.createVNode(U,{value:w.value.field.dataFormat,"onUpdate:value":u[38]||(u[38]=B=>w.value.field.dataFormat=B)},null,8,["value"])]),_:1})):i.createCommentVNode("",!0),w.value.widget.name=="unione-select-box"?(i.openBlock(),i.createBlock(T,{key:1,label:"下拉框类型"},{default:i.withCtx(()=>[i.createVNode(C,{value:w.value.widget.props.mode,"onUpdate:value":u[39]||(u[39]=B=>w.value.widget.props.mode=B),allowClear:!0},{default:i.withCtx(()=>[i.createVNode(E,{value:"multiple"},{default:i.withCtx(()=>u[60]||(u[60]=[i.createTextVNode("多选")])),_:1}),i.createVNode(E,{value:"tags"},{default:i.withCtx(()=>u[61]||(u[61]=[i.createTextVNode("标签")])),_:1})]),_:1},8,["value"])]),_:1})):i.createCommentVNode("",!0)]),_:1},8,["model"])]),_:1},8,["visible","onOk"]),i.createVNode(A,{visible:b.value.visible,"onUpdate:visible":u[49]||(u[49]=B=>b.value.visible=B),width:600,title:"规则设置",onOk:b.value.toSetting},{default:i.withCtx(()=>[i.createVNode(L,{model:b.value.props,name:"basic","label-col":{span:6},"wrapper-col":{span:18},autocomplete:"off",class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(j,{title:"基本设置",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"触发时机"},{default:i.withCtx(()=>[i.createVNode(G,{value:b.value.props.trigger,"onUpdate:value":u[41]||(u[41]=B=>b.value.props.trigger=B),options:["change","blur"]},null,8,["value"])]),_:1}),b.value.field.isNull?i.createCommentVNode("",!0):(i.openBlock(),i.createBlock(T,{key:0,label:"忽略空格",class:"checkbox-tips"},{default:i.withCtx(()=>[i.createVNode(x,{checked:b.value.props.whitespace,"onUpdate:checked":u[42]||(u[42]=B=>b.value.props.whitespace=B)},{default:i.withCtx(()=>u[62]||(u[62]=[i.createTextVNode(" 必填验证开启时,是否忽略空格 ")])),_:1},8,["checked"])]),_:1})),i.createVNode(T,{label:"预设类型"},{default:i.withCtx(()=>[i.createVNode(C,{options:b.value.advances,fieldNames:{label:"title",value:"name"},value:b.value.props.advance,"onUpdate:value":u[43]||(u[43]=B=>b.value.props.advance=B)},null,8,["options","value"])]),_:1})]),_:1}),["Long","Short","Integer","Float","Double"].includes(b.value.field.dataType)?(i.openBlock(),i.createBlock(j,{key:0,title:"数值验证",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"有效区间"},{default:i.withCtx(()=>[i.createVNode(I,{value:b.value.props.rangeMin,"onUpdate:value":u[44]||(u[44]=B=>b.value.props.rangeMin=B)},null,8,["value"]),u[63]||(u[63]=i.createElementVNode("span",{style:{margin:"auto 5px"}},null,-1)),i.createVNode(I,{value:b.value.props.rangeMax,"onUpdate:value":u[45]||(u[45]=B=>b.value.props.rangeMax=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.rangeMessage,"onUpdate:value":u[46]||(u[46]=B=>b.value.props.rangeMessage=B)},null,8,["value"])]),_:1})]),_:1})):i.createCommentVNode("",!0),i.createVNode(j,{title:"正则验证",type:"line"},{default:i.withCtx(()=>[i.createVNode(T,{label:"表达式"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.regExpress,"onUpdate:value":u[47]||(u[47]=B=>b.value.props.regExpress=B)},null,8,["value"])]),_:1}),i.createVNode(T,{label:"错误提示"},{default:i.withCtx(()=>[i.createVNode(U,{value:b.value.props.regMessage,"onUpdate:value":u[48]||(u[48]=B=>b.value.props.regMessage=B)},null,8,["value"])]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-d5938ab8"]]),lf={class:"unione-props-setting data-field-fkey"},sf={key:0},of=["onClick"],af=["onClick"],rf=["onClick"],df=["onClick"],cf=["onClick"],hf=["onClick"],ff=["onClick"],uf=["onClick"],pf=ne(i.defineComponent({__name:"dataFieldFKeys",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=K.useDialog(),t=i.ref([{title:"序号",dataIndex:"index",key:"index",width:"35px",fixed:"left",align:"center",customRender:({index:p})=>p+1},{title:"字段名称",dataIndex:"name",key:"name",width:"100px",fixed:"left",align:"center"},{title:"字段标题",dataIndex:"title",key:"title",width:"100px",fixed:"left",align:"center"},{title:"关联数据名称",dataIndex:"dsnName",key:"dsnName",width:"120px",align:"center"},{title:"关联数据标题",dataIndex:"dsnTitle",key:"dsnTitle",width:"150px",align:"center"},{title:"关联字段",dataIndex:"fieldName",key:"fieldName",width:"100px",align:"center"},{title:"显示字段",dataIndex:"labelName",key:"labelName",width:"120px",align:"center"}]),n=i.useModel(a,"modelValue"),l=i.computed(()=>n.value.filter(p=>p.configs?.fkey?.enable)||[]),s=i.ref({});function o(){s.value={}}function r(p,m){o();const b={};b[m]=p.configs.fkey[m]||"",s.value[p.name]=b}function d(p,m,b){p.configs.fkey.dsn=m,p.configs.fkey.dsnName=b.name,p.configs.fkey.dsnTitle=b.title,p.configs.fkey.dsnId=b.id}function h(p,m,b,y){p.configs.fkey[m]=b,m=="fieldName"&&(p.configs.fkey.fieldTitle=y.title),m=="labelName"&&(p.configs.fkey.labelTitle=y.title)}function f(p){c.value.record=p,c.value.visible=!0,c.value.fields=p.configs?.fkey?.fields||[]}const c=i.ref({visible:!1,record:null,editField:{},fields:[],columns:[{title:"字段名称",dataIndex:"title",key:"title",width:"100px",align:"center"},{title:"显示宽度",dataIndex:"width",key:"width",width:"60px",align:"center"},{title:"显示顺序",dataIndex:"index",key:"index",width:"60px",align:"center"},{title:"操作",dataIndex:"action",key:"action",width:"60px",align:"center"}],toEditField:(p,m)=>{c.value.editField[p]=m},onShowFieldChange:(p,m,b)=>{p.name=b.name,p.title=b.title},toAddField:()=>{c.value.fields.push({name:"",title:""}),c.value.editField[c.value.fields.length-1]="title"},toDelField:p=>{e.confirm({content:"确定要删除该字段么?",onOk:()=>{c.value.fields.splice(p,1)}})},toSetting:()=>{c.value.visible=!1,c.value.record.configs=K.utils.obj.ext(c.value.record.configs,{fkey:{fields:c.value.fields}})}});return(p,m)=>{const b=i.resolveComponent("FormOutlined"),y=i.resolveComponent("unione-select-box"),w=i.resolveComponent("a-button"),v=i.resolveComponent("a-table"),k=i.resolveComponent("a-input-number"),O=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",lf,[i.createVNode(v,{columns:t.value,"data-source":l.value,bordered:"","row-key":"name",size:"small",pagination:!1},{headerCell:i.withCtx(({column:g})=>[["dsnName","dsnTitle","fieldName","labelName"].includes(g.key)?(i.openBlock(),i.createElementBlock("span",sf,[i.createVNode(b),i.createTextVNode(" "+i.toDisplayString(g.title),1)])):i.createCommentVNode("",!0)]),bodyCell:i.withCtx(({column:g,record:u})=>[["dsnName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",(!s.value[u.name]||!Object.keys(s.value[u.name]).includes(g.dataIndex))&&!u.configs?.fkey?.dsnName&&"empty"]),onClick:N=>r(u,g.dataIndex)},[s.value[u.name]&&Object.keys(s.value[u.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[u.name][g.dataIndex],"onUpdate:value":N=>s.value[u.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/define/find",valueField:"sn",labelField:"name",search:!0},onBlur:o,onSelect:(N,V)=>d(u,N,V)},null,8,["value","onUpdate:value","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(u.configs?.fkey?.dsnName),1)],64))],10,of)):["dsnTitle"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",(!s.value[u.name]||!Object.keys(s.value[u.name]).includes(g.dataIndex))&&!u.configs?.fkey?.dsnTitle&&"empty"]),onClick:N=>r(u,g.dataIndex)},[s.value[u.name]&&Object.keys(s.value[u.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[u.name][g.dataIndex],"onUpdate:value":N=>s.value[u.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/define/find",valueField:"sn",labelField:"title",search:!0},onBlur:o,onSelect:(N,V)=>d(u,N,V)},null,8,["value","onUpdate:value","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(u.configs?.fkey?.dsnTitle),1)],64))],10,af)):i.createCommentVNode("",!0),["fieldName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",(!s.value[u.name]||!Object.keys(s.value[u.name]).includes(g.dataIndex))&&!u.configs?.fkey?.fieldName&&"empty"]),onClick:N=>r(u,g.dataIndex)},[s.value[u.name]&&u.configs?.fkey?.dsn&&Object.keys(s.value[u.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[u.name][g.dataIndex],"onUpdate:value":N=>s.value[u.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/field/find",params:{body:{defineId:u.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:o,onSelect:(N,V)=>h(u,"fieldName",N,V)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(u.configs?.fkey?.fieldTitle),1)],64))],10,rf)):["labelName"].includes(g.dataIndex)?(i.openBlock(),i.createElementBlock("div",{key:3,class:i.normalizeClass(["edit-field",(!s.value[u.name]||!Object.keys(s.value[u.name]).includes(g.dataIndex))&&!u.configs?.fkey?.labelName&&"empty"]),onClick:N=>r(u,g.dataIndex)},[s.value[u.name]&&u.configs?.fkey?.dsn&&Object.keys(s.value[u.name]).includes(g.dataIndex)?(i.openBlock(),i.createBlock(y,{key:0,value:s.value[u.name][g.dataIndex],"onUpdate:value":N=>s.value[u.name][g.dataIndex]=N,convert:{types:"local",url:"/api/data/field/find",params:{body:{defineId:u.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:o,onSelect:(N,V)=>h(u,"labelName",N,V)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(u.configs?.fkey?.labelTitle)+" ",1),u.configs?.fkey?.labelName?(i.openBlock(),i.createBlock(w,{key:0,type:"link",onClick:i.withModifiers(N=>f(u),["stop"])},{default:i.withCtx(()=>m[4]||(m[4]=[i.createTextVNode("设置")])),_:2},1032,["onClick"])):i.createCommentVNode("",!0)],64))],10,df)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"]),i.createVNode(O,{visible:c.value.visible,"onUpdate:visible":m[3]||(m[3]=g=>c.value.visible=g),width:600,title:"更多显示字段",class:"data-field-fkey",onOk:c.value.toSetting},{default:i.withCtx(()=>[i.createVNode(w,{class:"editable-add-btn",style:{"margin-bottom":"8px"},onClick:c.value.toAddField},{default:i.withCtx(()=>m[5]||(m[5]=[i.createTextVNode("新增")])),_:1},8,["onClick"]),i.createVNode(v,{columns:c.value.columns,"data-source":c.value.fields,size:"small"},{bodyCell:i.withCtx(({column:g,record:u,index:N,text:V})=>[g.dataIndex==="title"?(i.openBlock(),i.createElementBlock("div",{key:0,class:i.normalizeClass(["edit-field",c.value.editField!="title"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="title"?(i.openBlock(),i.createBlock(y,{key:0,value:u[u.dataIndex],"onUpdate:value":C=>u[u.dataIndex]=C,convert:{types:"local",url:"/api/data/field/find",search:!0,params:{body:{defineId:c.value.record.configs.fkey.dsnId},pageSize:1e3},valueField:"name",labelField:"title"},onBlur:m[0]||(m[0]=C=>c.value.editField={}),onSelect:(C,x)=>c.value.onShowFieldChange(u,C,x)},null,8,["value","onUpdate:value","convert","onSelect"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,cf)):i.createCommentVNode("",!0),g.dataIndex==="width"?(i.openBlock(),i.createElementBlock("div",{key:1,class:i.normalizeClass(["edit-field",c.value.editField!="width"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="width"?(i.openBlock(),i.createBlock(k,{key:0,onBlur:m[1]||(m[1]=C=>c.value.editField={}),value:u.width,"onUpdate:value":C=>u.width=C,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,hf)):i.createCommentVNode("",!0),g.dataIndex==="index"?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["edit-field",c.value.editField!="wiindexdth"&&!V&&"empty"]),onClick:C=>c.value.toEditField(N,g.dataIndex)},[c.value.editField[N]=="index"?(i.openBlock(),i.createBlock(k,{key:0,onBlur:m[2]||(m[2]=C=>c.value.editField={}),value:u.index,"onUpdate:value":C=>u.index=C,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:1},[i.createTextVNode(i.toDisplayString(V),1)],64))],10,ff)):i.createCommentVNode("",!0),g.dataIndex==="action"?(i.openBlock(),i.createElementBlock("a",{key:3,onClick:C=>c.value.toDelField(N)},"删除",8,uf)):i.createCommentVNode("",!0)]),_:1},8,["columns","data-source"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-84143692"]]),mf={class:"unione-props-setting data-filter"},gf={class:"title"},kf={class:"name"},bf={class:"action"},yf=ne(i.defineComponent({__name:"dataFilters",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(a){const e=K.useDialog(),t=i.useModel(a,"modelValue");function n(){r.value.visible=!0,r.value.filter={},r.value.name=null}function l(h){r.value.visible=!0,r.value.filter={...h},r.value.name=h.name}function s(h){e.confirm({content:"确定要删除该过滤对象么?",onOk:()=>{t.value.splice(h,1)}})}const o=i.ref(),r=i.ref({visible:!1,name:null,filter:{},rules:{title:[{required:!0,message:"过滤标题不能为空"}],name:[{required:!0,message:"过滤名称不能为空"}],filter:[{required:!0,message:"过滤脚本不能为空"}]},toSetting:()=>{o.value.validate().then(h=>{if(r.value.name){const f=t.value.filter(c=>c.name==r.value.name)[0];if(!f){e.error({content:"过滤记录未找到"});return}if(r.value.name!=r.value.filter.name&&t.value.filter(p=>p.name==r.value.filter.name).length){e.error({content:"过滤名称已存在!"});return}Object.keys(h).forEach(c=>{f[c]=h[c]})}else{if(t.value.filter(c=>c.name==r.value.filter.name).length){e.error({content:"过滤名称已存在!"});return}t.value.push(h)}r.value.visible=!1})}});function d(){const h=[];r.value.filter.filter||(r.value.filter.filter=""),h.push("-- @if(isNotEmpty(params."),h.push(r.value.filter.name||"xxx"),h.push(") && !isBlank(params."),h.push(r.value.filter.name||"xxx"),h.push(`)
11
11
  `),h.push(" AND XXX=#{params."),h.push(r.value.filter.name||"xxx"),h.push(`}
12
12
  `),h.push(`-- @}
13
- `),r.value.filter.filter=r.value.filter.filter+h.join("")}return(h,f)=>{const c=i.resolveComponent("a-button"),u=i.resolveComponent("a-card"),m=i.resolveComponent("PlusOutlined"),b=i.resolveComponent("a-empty"),y=i.resolveComponent("a-input"),k=i.resolveComponent("a-form-item"),v=i.resolveComponent("a-textarea"),w=i.resolveComponent("a-tag"),O=i.resolveComponent("a-form"),g=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",mf,[(t.value.length,i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(t.value,(p,N)=>(i.openBlock(),i.createBlock(u,{class:"filter-box",size:"small",key:N},{default:i.withCtx(()=>[i.createElementVNode("div",gf,"过滤标题:"+i.toDisplayString(p.title),1),i.createElementVNode("div",kf,"过滤名称:"+i.toDisplayString(p.name),1),i.createElementVNode("div",bf,[i.createVNode(c,{size:"small",onClick:V=>l(p)},{default:i.withCtx(()=>f[4]||(f[4]=[i.createTextVNode("编辑")])),_:2},1032,["onClick"]),i.createVNode(c,{danger:"",size:"small",onClick:V=>s(N)},{default:i.withCtx(()=>f[5]||(f[5]=[i.createTextVNode("删除")])),_:2},1032,["onClick"])])]),_:2},1024))),128)),i.createVNode(u,{class:"filter-box btn-add",size:"small",onClick:n},{default:i.withCtx(()=>[i.createVNode(m,{class:"btn"})]),_:1})],64)),i.createVNode(g,{visible:r.value.visible,"onUpdate:visible":f[3]||(f[3]=p=>r.value.visible=p),width:600,title:"设置数据过滤",class:"data-filter",onOk:r.value.toSetting},{default:i.withCtx(()=>[i.createVNode(O,{ref_key:"filterForm",ref:a,model:r.value.filter,rules:r.value.rules,name:"basic","label-col":{span:4},"wrapper-col":{span:18},class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(k,{label:"过滤标题",name:"title"},{default:i.withCtx(()=>[i.createVNode(y,{value:r.value.filter.title,"onUpdate:value":f[0]||(f[0]=p=>r.value.filter.title=p)},null,8,["value"])]),_:1}),i.createVNode(k,{label:"过滤名称",name:"name"},{default:i.withCtx(()=>[i.createVNode(y,{value:r.value.filter.name,"onUpdate:value":f[1]||(f[1]=p=>r.value.filter.name=p)},null,8,["value"])]),_:1}),i.createVNode(k,{label:"过滤脚本",name:"filter",tooltip:"使用beetsql语法,参数获取方式params.xxx,判断参数是否为空isNotEmpty(params.xxx) && !isBlank(params.xxx)"},{default:i.withCtx(()=>[i.createVNode(v,{value:r.value.filter.filter,"onUpdate:value":f[2]||(f[2]=p=>r.value.filter.filter=p),autosize:{minRows:10},style:{"padding-top":"20px"}},null,8,["value"]),i.createVNode(w,{class:"btn-tmpl",color:"blue",onClick:d},{default:i.withCtx(()=>f[6]||(f[6]=[i.createTextVNode("插入模版")])),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-a600b93f"]]),wf={class:"unione-page form-page data-define-edit"},xf={class:"actions"},vf=ne(i.defineComponent({__name:"edit",setup(o){const e=K.useDialog(),t=i.inject("route"),n=i.inject("router"),l=i.ref(),s=i.ref({isPrimary:!1,fields:[{title:"数据类型",name:"category",control:"unione-select-box",value:"sql",convert:{types:"dict",dictName:"DATACATEGORY"}},{title:"数据源",name:"dsId",control:"unione-select-box",convert:{types:"local",url:"/api/data/source/find",search:!0},props:{required:!0}},{title:"自定义",name:"isCustom",control:"unione-switch-box",value:0,convert:{types:"dict",dictName:"TUREORFALSE"}},{title:"数据标题",name:"title",dataLen:10,props:{required:!0}},{title:"数据名称",name:"name",props:{required:!0},rules:{whitespace:!0}},{title:"数据编码",name:"sn",dataLen:50},{title:"描述",name:"descs",control:"a-textarea",view:{width:3}}],setting:{showColumn:2,labelWidth:6}}),a=i.ref(),r=i.ref({isPrimary:!1,fields:[{title:"列表模版",name:"listTmpl",control:"unione-select-box",value:"normal",convert:{types:"option",options:[{value:"normal",label:"标准"}]},props:{required:!0}},{title:"表单风格",name:"showColumn",control:"unione-select-box",value:2,convert:{types:"option",options:[{value:1,label:"一列"},{value:2,label:"二列"},{value:3,label:"三列"}]},props:{required:!0}},{title:"标题宽度",name:"labelWidth",control:"a-input-number",value:9,rule:{rangeMin:1,rangeMax:24},props:{required:!0}}],setting:{showColumn:2,labelWidth:6}}),d=i.ref({configs:{fields:[],filters:[]}}),h=i.ref(!1);function f(){n.back()}function c(){e.confirm({content:"确定要发布当前数据么?",onOk:()=>{ft.release([d.value.id]).then(y=>{y.success?(e.success({title:"发布成功",content:y.body}),b(d.value.id)):e.error({title:"发布失败",content:y.body})})}})}async function u(){const y=await l.value.validate(),k={...d.value,...y};k.configs.show=await a.value.getValue(),console.log("formData",k),J.message.loading({content:"提交中..."}),h.value=!0,ft.save(k).then(v=>{J.message.destroy(),v.success?(d.value=v.body,l.value.setValue(v.body),a.value.setValue(v.body.configs?.show||{}),J.message.success("保存成功!")):J.message.error(v.message)}).finally(()=>{h.value=!1})}const m=i.ref(!1);i.onMounted(()=>{t.query.id&&b(t.query.id)});function b(y){J.message.loading({content:"加载中..."}),ft.detail(y).then(k=>{k.success?(d.value=k.body,l.value.setValue(k.body),a.value.setValue(k.body.configs?.show||{}),J.message.destroy()):J.message.error(k.message)})}return(y,k)=>{const v=i.resolveComponent("unione-form"),w=i.resolveComponent("unione-section"),O=i.resolveComponent("OrderedListOutlined"),g=i.resolveComponent("a-tab-pane"),p=i.resolveComponent("ToolOutlined"),N=i.resolveComponent("ApiOutlined"),V=i.resolveComponent("FunnelPlotOutlined"),C=i.resolveComponent("a-tabs"),x=i.resolveComponent("a-button");return i.openBlock(),i.createElementBlock("div",wf,[i.createVNode(w,{title:"基础信息",type:"line"},{default:i.withCtx(()=>[i.createVNode(v,{form:s.value,ref_key:"formBaseObj",ref:l},null,8,["form"])]),_:1}),i.createVNode(w,{class:"page-setting-section",title:"页面配置",type:m.value&&"line",location:m.value?"left":"right",reactive:"",modelValue:m.value,"onUpdate:modelValue":k[0]||(k[0]=S=>m.value=S)},{default:i.withCtx(()=>[i.createVNode(v,{form:r.value,ref_key:"pageSettingObj",ref:a},null,8,["form"])]),_:1},8,["type","location","modelValue"]),i.createVNode(C,null,{default:i.withCtx(()=>[i.createVNode(g,{key:"field-mange"},{tab:i.withCtx(()=>[i.createVNode(O),k[5]||(k[5]=i.createTextVNode("字段管理 "))]),default:i.withCtx(()=>[i.createVNode(pd,{modelValue:d.value.configs.fields,"onUpdate:modelValue":k[1]||(k[1]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"field-setting"},{tab:i.withCtx(()=>[i.createVNode(p),k[6]||(k[6]=i.createTextVNode("字段设置 "))]),default:i.withCtx(()=>[i.createVNode(nf,{modelValue:d.value.configs.fields,"onUpdate:modelValue":k[2]||(k[2]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"field-fkeys"},{tab:i.withCtx(()=>[i.createVNode(N),k[7]||(k[7]=i.createTextVNode("外键设置 "))]),default:i.withCtx(()=>[i.createVNode(pf,{modelValue:d.value.configs.fields,"onUpdate:modelValue":k[3]||(k[3]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"data-filter"},{tab:i.withCtx(()=>[i.createVNode(V),k[8]||(k[8]=i.createTextVNode("数据过滤 "))]),default:i.withCtx(()=>[i.createVNode(yf,{modelValue:d.value.configs.filters,"onUpdate:modelValue":k[4]||(k[4]=S=>d.value.configs.filters=S)},null,8,["modelValue"])]),_:1})]),_:1}),i.createElementVNode("div",xf,[i.createVNode(x,{type:"primary",onClick:u,loading:h.value},{default:i.withCtx(()=>k[9]||(k[9]=[i.createTextVNode("保存")])),_:1},8,["loading"]),d.value.id?(i.openBlock(),i.createBlock(x,{key:0,danger:"",onClick:c,loading:h.value},{default:i.withCtx(()=>k[10]||(k[10]=[i.createTextVNode("发布")])),_:1},8,["loading"])):i.createCommentVNode("",!0),i.createVNode(x,{onClick:f},{default:i.withCtx(()=>k[11]||(k[11]=[i.createTextVNode("返回")])),_:1})])])}}}),[["__scopeId","data-v-3eeab6e6"]]),Cf={UnioneEditor:ct,locales:Zi,loadConfig:Ie,DataStorage:en,Convertor:Ke,install(o,e){K.loadConfig(e);const t=Ie(e);t.axios&&K.axios.create(t.axios),o.component("UnioneBtn",ya),o.component("UnioneTabs",xa),o.component("UnioneSection",Oa),o.component("UnioneQuery",vl),o.component("UnioneTable",Cl),o.component("UnioneFormItem",Wa),o.component("UnioneForm",ja),o.component("UnioneSelectBox",Ha),o.component("UnioneSwitchBox",Ka),o.component("UnioneRadioBox",Qa),o.component("UnioneCheckBox",Ga),o.component("UnionePwdBox",Ya),o.component("UnionePageEditor",Sl),o.component("UnionePageForm",Nl),o.component("UnionePageTree",Bl),o.component("UnionePageList",Ol)}};ee.Convertor=Ke,ee.DataStorage=en,ee.UnioneDataDefineEdit=vf,ee.UnioneDataDefineList=od,ee.UnioneEditor=ct,ee.UnionePage=jt,ee.UnionePageEditor=Sl,ee.UnionePageForm=Nl,ee.UnionePageList=Ol,ee.UnionePageSetting=zt,ee.UnionePageTree=Bl,ee.UnioneQueryForm=vl,ee.UnioneTableList=Cl,ee.default=Cf,ee.loadConfig=Ie,ee.locales=Zi,ee.useDebounce=tn,ee.utils=gr,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
13
+ `),r.value.filter.filter=r.value.filter.filter+h.join("")}return(h,f)=>{const c=i.resolveComponent("a-button"),p=i.resolveComponent("a-card"),m=i.resolveComponent("PlusOutlined"),b=i.resolveComponent("a-empty"),y=i.resolveComponent("a-input"),w=i.resolveComponent("a-form-item"),v=i.resolveComponent("a-textarea"),k=i.resolveComponent("a-tag"),O=i.resolveComponent("a-form"),g=i.resolveComponent("a-modal");return i.openBlock(),i.createElementBlock("div",mf,[(t.value.length,i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(t.value,(u,N)=>(i.openBlock(),i.createBlock(p,{class:"filter-box",size:"small",key:N},{default:i.withCtx(()=>[i.createElementVNode("div",gf,"过滤标题:"+i.toDisplayString(u.title),1),i.createElementVNode("div",kf,"过滤名称:"+i.toDisplayString(u.name),1),i.createElementVNode("div",bf,[i.createVNode(c,{size:"small",onClick:V=>l(u)},{default:i.withCtx(()=>f[4]||(f[4]=[i.createTextVNode("编辑")])),_:2},1032,["onClick"]),i.createVNode(c,{danger:"",size:"small",onClick:V=>s(N)},{default:i.withCtx(()=>f[5]||(f[5]=[i.createTextVNode("删除")])),_:2},1032,["onClick"])])]),_:2},1024))),128)),i.createVNode(p,{class:"filter-box btn-add",size:"small",onClick:n},{default:i.withCtx(()=>[i.createVNode(m,{class:"btn"})]),_:1})],64)),i.createVNode(g,{visible:r.value.visible,"onUpdate:visible":f[3]||(f[3]=u=>r.value.visible=u),width:600,title:"设置数据过滤",class:"data-filter",onOk:r.value.toSetting},{default:i.withCtx(()=>[i.createVNode(O,{ref_key:"filterForm",ref:o,model:r.value.filter,rules:r.value.rules,name:"basic","label-col":{span:4},"wrapper-col":{span:18},class:"form-mix"},{default:i.withCtx(()=>[i.createVNode(w,{label:"过滤标题",name:"title"},{default:i.withCtx(()=>[i.createVNode(y,{value:r.value.filter.title,"onUpdate:value":f[0]||(f[0]=u=>r.value.filter.title=u)},null,8,["value"])]),_:1}),i.createVNode(w,{label:"过滤名称",name:"name"},{default:i.withCtx(()=>[i.createVNode(y,{value:r.value.filter.name,"onUpdate:value":f[1]||(f[1]=u=>r.value.filter.name=u)},null,8,["value"])]),_:1}),i.createVNode(w,{label:"过滤脚本",name:"filter",tooltip:"使用beetsql语法,参数获取方式params.xxx,判断参数是否为空isNotEmpty(params.xxx) && !isBlank(params.xxx)"},{default:i.withCtx(()=>[i.createVNode(v,{value:r.value.filter.filter,"onUpdate:value":f[2]||(f[2]=u=>r.value.filter.filter=u),autosize:{minRows:10},style:{"padding-top":"20px"}},null,8,["value"]),i.createVNode(k,{class:"btn-tmpl",color:"blue",onClick:d},{default:i.withCtx(()=>f[6]||(f[6]=[i.createTextVNode("插入模版")])),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["visible","onOk"])])}}}),[["__scopeId","data-v-a600b93f"]]),wf={class:"unione-page form-page data-define-edit"},xf={class:"actions"},vf=ne(i.defineComponent({__name:"edit",setup(a){const e=K.useDialog(),t=i.inject("route"),n=i.inject("router"),l=i.ref(),s=i.ref({isPrimary:!1,fields:[{title:"数据类型",name:"category",control:"unione-select-box",value:"sql",convert:{types:"dict",dictName:"DATACATEGORY"}},{title:"数据源",name:"dsId",control:"unione-select-box",convert:{types:"local",url:"/api/data/source/find",search:!0},props:{required:!0}},{title:"自定义",name:"isCustom",control:"unione-switch-box",value:0,convert:{types:"dict",dictName:"TUREORFALSE"}},{title:"数据标题",name:"title",dataLen:10,props:{required:!0}},{title:"数据名称",name:"name",props:{required:!0},rules:{whitespace:!0}},{title:"数据编码",name:"sn",dataLen:50},{title:"描述",name:"descs",control:"a-textarea",view:{width:3}}],setting:{showColumn:2,labelWidth:6}}),o=i.ref(),r=i.ref({isPrimary:!1,fields:[{title:"列表模版",name:"listTmpl",control:"unione-select-box",value:"normal",convert:{types:"option",options:[{value:"normal",label:"标准"}]},props:{required:!0}},{title:"表单风格",name:"showColumn",control:"unione-select-box",value:2,convert:{types:"option",options:[{value:1,label:"一列"},{value:2,label:"二列"},{value:3,label:"三列"}]},props:{required:!0}},{title:"标题宽度",name:"labelWidth",control:"a-input-number",value:9,rule:{rangeMin:1,rangeMax:24},props:{required:!0}}],setting:{showColumn:2,labelWidth:6}}),d=i.ref({configs:{fields:[],filters:[]}}),h=i.ref(!1);function f(){n.back()}function c(){e.confirm({content:"确定要发布当前数据么?",onOk:()=>{ft.release([d.value.id]).then(y=>{y.success?(e.success({title:"发布成功",content:y.body}),b(d.value.id)):e.error({title:"发布失败",content:y.body})})}})}async function p(){const y=await l.value.validate(),w={...d.value,...y};w.configs.show=await o.value.getValue(),console.log("formData",w),J.message.loading({content:"提交中..."}),h.value=!0,ft.save(w).then(v=>{J.message.destroy(),v.success?(d.value=v.body,l.value.setValue(v.body),o.value.setValue(v.body.configs?.show||{}),J.message.success("保存成功!")):J.message.error(v.message)}).finally(()=>{h.value=!1})}const m=i.ref(!1);i.onMounted(()=>{t.query.id&&b(t.query.id)});function b(y){J.message.loading({content:"加载中..."}),ft.detail(y).then(w=>{w.success?(d.value=w.body,l.value.setValue(w.body),o.value.setValue(w.body.configs?.show||{}),J.message.destroy()):J.message.error(w.message)})}return(y,w)=>{const v=i.resolveComponent("unione-form"),k=i.resolveComponent("unione-section"),O=i.resolveComponent("OrderedListOutlined"),g=i.resolveComponent("a-tab-pane"),u=i.resolveComponent("ToolOutlined"),N=i.resolveComponent("ApiOutlined"),V=i.resolveComponent("FunnelPlotOutlined"),C=i.resolveComponent("a-tabs"),x=i.resolveComponent("a-button");return i.openBlock(),i.createElementBlock("div",wf,[i.createVNode(k,{title:"基础信息",type:"line"},{default:i.withCtx(()=>[i.createVNode(v,{form:s.value,ref_key:"formBaseObj",ref:l},null,8,["form"])]),_:1}),i.createVNode(k,{class:"page-setting-section",title:"页面配置",type:m.value&&"line",location:m.value?"left":"right",reactive:"",modelValue:m.value,"onUpdate:modelValue":w[0]||(w[0]=S=>m.value=S)},{default:i.withCtx(()=>[i.createVNode(v,{form:r.value,ref_key:"pageSettingObj",ref:o},null,8,["form"])]),_:1},8,["type","location","modelValue"]),i.createVNode(C,null,{default:i.withCtx(()=>[i.createVNode(g,{key:"field-mange"},{tab:i.withCtx(()=>[i.createVNode(O),w[5]||(w[5]=i.createTextVNode("字段管理 "))]),default:i.withCtx(()=>[i.createVNode(pd,{modelValue:d.value.configs.fields,"onUpdate:modelValue":w[1]||(w[1]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"field-setting"},{tab:i.withCtx(()=>[i.createVNode(u),w[6]||(w[6]=i.createTextVNode("字段设置 "))]),default:i.withCtx(()=>[i.createVNode(nf,{modelValue:d.value.configs.fields,"onUpdate:modelValue":w[2]||(w[2]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"field-fkeys"},{tab:i.withCtx(()=>[i.createVNode(N),w[7]||(w[7]=i.createTextVNode("外键设置 "))]),default:i.withCtx(()=>[i.createVNode(pf,{modelValue:d.value.configs.fields,"onUpdate:modelValue":w[3]||(w[3]=S=>d.value.configs.fields=S)},null,8,["modelValue"])]),_:1}),i.createVNode(g,{key:"data-filter"},{tab:i.withCtx(()=>[i.createVNode(V),w[8]||(w[8]=i.createTextVNode("数据过滤 "))]),default:i.withCtx(()=>[i.createVNode(yf,{modelValue:d.value.configs.filters,"onUpdate:modelValue":w[4]||(w[4]=S=>d.value.configs.filters=S)},null,8,["modelValue"])]),_:1})]),_:1}),i.createElementVNode("div",xf,[i.createVNode(x,{type:"primary",onClick:p,loading:h.value},{default:i.withCtx(()=>w[9]||(w[9]=[i.createTextVNode("保存")])),_:1},8,["loading"]),d.value.id?(i.openBlock(),i.createBlock(x,{key:0,danger:"",onClick:c,loading:h.value},{default:i.withCtx(()=>w[10]||(w[10]=[i.createTextVNode("发布")])),_:1},8,["loading"])):i.createCommentVNode("",!0),i.createVNode(x,{onClick:f},{default:i.withCtx(()=>w[11]||(w[11]=[i.createTextVNode("返回")])),_:1})])])}}}),[["__scopeId","data-v-3eeab6e6"]]),Cf={UnioneEditor:ct,locales:Zi,loadConfig:Ie,DataStorage:en,Convertor:Ke,install(a,e){K.loadConfig(e);const t=Ie(e);t.axios&&K.axios.create(t.axios),a.component("UnioneBtn",ya),a.component("UnioneTabs",xa),a.component("UnioneSection",Oa),a.component("UnioneQuery",vl),a.component("UnioneTable",Cl),a.component("UnioneFormItem",Wa),a.component("UnioneForm",ja),a.component("UnioneSelectBox",Ha),a.component("UnioneSwitchBox",Ka),a.component("UnioneRadioBox",Qa),a.component("UnioneCheckBox",Ga),a.component("UnionePwdBox",Ya),a.component("UnionePageEditor",Sl),a.component("UnionePageForm",Nl),a.component("UnionePageTree",Bl),a.component("UnionePageList",Ol)}};ee.Convertor=Ke,ee.DataStorage=en,ee.UnioneDataDefineEdit=vf,ee.UnioneDataDefineList=od,ee.UnioneEditor=ct,ee.UnionePage=jt,ee.UnionePageEditor=Sl,ee.UnionePageForm=Nl,ee.UnionePageList=Ol,ee.UnionePageSetting=zt,ee.UnionePageTree=Bl,ee.UnioneQueryForm=vl,ee.UnioneTableList=Cl,ee.default=Cf,ee.loadConfig=Ie,ee.locales=Zi,ee.useDebounce=tn,ee.utils=gr,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});