import{t as i,a3 as r,a4 as o,a5 as h,a1 as p}from"./index-DOFLUERq.js";import{u as m}from"./store-7aRonVWq.js";import n from"./SchemaBuilder-wAjSIw8d.js";import"./SchemaCanvas-BgHWwIOY.js";import"./SchemaTabs-B-YYDirE.js";import"./EditableInput-DQlgWBJl.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./SchemaSections-BAEJPWaR.js";import"./vuedraggable.umd-CrsnNXKf.js";import"./_commonjsHelpers-CE1G-McA.js";import"./index-CRx3oDcD.js";import"./index-DuPUrsw1.js";import"./SchemaSidebar-DbURj86H.js";class c{constructor({wrapper:t,frm:e,pagetype:s,customize:a}){this.$wrapper=$(t),this.frm=e,this.page=e.page,this.pagetype=s,this.customize=a,this.read_only=!1,this.init()}init(t){this.page.set_title(i(this.pagetype)),!t&&this.setup_app(),t&&this.update_store(),this.watch_changes()}setup_app(){let t=r(),e=o(n);e.use(t),e.use(h),this.store=m(),this.update_store(),this.$schema_builder=e.mount(this.$wrapper.get(0))}update_store(){this.store.pagetype=this.pagetype,this.store.is_customize_form=this.customize,this.store.page=this.page,this.store.frm=this.frm}watch_changes(){p(()=>{if(this.store.dirty||this.frm.is_dirty()?this.frm.dirty():this.page.clear_indicator(),this.store.read_only){let t=this.store.preview?i("Preview Mode"):i("Read Only");this.page.set_indicator(t,"orange")}})}getSchemaData(){return this.store&&this.store.schema?(this.store.updateSchema(),this.store.schema):null}saveSchemaToForm(){const t=this.getSchemaData();t&&this.frm&&(this.frm.set_value("node_schema",JSON.stringify(t,null,2)),this.frm.save().then(()=>{}).catch(e=>{console.error(`保存失败: ${e.message}`)}))}triggerSave(){if(this.$wrapper&&this.$wrapper[0]){const t=new CustomEvent("schema-save",{detail:{schemaData:this.getSchemaData()}});this.$wrapper[0].dispatchEvent(t)}}}typeof window<"u"&&(window.jingrow||(window.jingrow={}),window.jingrow.ui||(window.jingrow.ui={}),window.jingrow.ui.SchemaBuilder=c);export{c as default};
