import{api as V,getRecord as L}from"./common-DEIQtiPI.js";import{L as E}from"./LinkField-CPzmuCgV.js";import{d as N,o as w,g as i,A as f,J as m,B as v,C as k,_ as h,P as _,j as y,az as b,K as P,L as S,O as U,r}from"./index-DOFLUERq.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./iconify-p99pbjf9.js";const j={key:0,class:"modules-editor"},H={class:"copy-from-field"},I={class:"editor-header"},R={class:"checkbox-grid"},z=N({__name:"HTML",props:{df:{},record:{},canEdit:{type:Boolean},ctx:{}},setup(s){const t=s,c=r([]),a=r([]),d=r(!1);function g(){const e=Array.isArray(t.record?.block_modules)?t.record.block_modules:[];a.value=e.map(l=>l.module).filter(Boolean)}async function M(){try{const e=await V.call("jingrow.core.pagetype.module_profile.module_profile.get_all_modules");c.value=e.message||[]}catch(e){console.error("Failed to load all modules:",e)}g(),d.value=a.value.length===0}function x(e){return!a.value.includes(e)}function A(){d.value?a.value=[]:a.value=[...c.value],u()}function B(e,l){l?a.value=a.value.filter(o=>o!==e):a.value.includes(e)||a.value.push(e),d.value=a.value.length===0,u()}function u(){if(!t.record)return;const e=Array.isArray(t.record.block_modules)?t.record.block_modules:[],l=e.map(o=>o.module);t.record.block_modules=e.filter(o=>a.value.includes(o.module)),a.value.forEach(o=>{l.includes(o)||t.record.block_modules.push({pagetype:"Block Module",module:o,__islocal:1})})}const p=r("");function C(e){e&&F(e)}async function F(e){if(e)try{const l=await L("Module Profile",e);if(l.success){const o=Array.isArray(l.data?.block_modules)?l.data.block_modules:[];a.value=o.map(n=>n.module).filter(Boolean),d.value=a.value.length===0,u()}}catch(l){console.error("Failed to copy modules:",l)}}return w(()=>{M()}),(e,l)=>c.value.length?(i(),f("div",j,[m("div",H,[v(E,{modelValue:p.value,"onUpdate:modelValue":[l[0]||(l[0]=o=>p.value=o),C],options:"Module Profile",label:s.ctx.t("Copy From"),"enable-create":!1},null,8,["modelValue","label"])]),m("div",I,[v(y(b),{checked:d.value,"onUpdate:checked":[l[1]||(l[1]=o=>d.value=o),A],disabled:!s.canEdit},{default:k(()=>[h(_(s.ctx.t("Select All")),1)]),_:1},8,["checked","disabled"])]),m("div",R,[(i(!0),f(P,null,S(c.value,o=>(i(),f("div",{key:o,class:"checkbox-item"},[v(y(b),{checked:x(o),"onUpdate:checked":n=>B(o,n),disabled:!s.canEdit},{default:k(()=>[h(_(s.ctx.t(o)),1)]),_:2},1032,["checked","onUpdate:checked","disabled"])]))),128))])])):U("",!0)}}),G=T(z,[["__scopeId","data-v-1f84336b"]]);export{G as default};
