import{j as e}from"./tanstack-1.0.74-aU0azVkW.js";import{l as b,al as s,dh as c}from"./lib-1.0.74-B5IEqfHg.js";import{B as g}from"./Box-1.0.74-DEbuVvGV.js";import{T as x,F as m,b as j}from"./TextField-1.0.74-BW9Byijb.js";import{F as v}from"./FormControlLabel-1.0.74-CdAG1Jo8.js";import{C as E}from"./Checkbox-1.0.74-DOdb-56q.js";import"./redux-1.0.74-D8bIc6ki.js";import"./vendor-1.0.74-CN03Eozo.js";import"./utils-1.0.74-7xWhx9mc.js";import"./CircularProgress-1.0.74-QfwfRJ7i.js";import"./Typography-1.0.74-B4mhsevh.js";import"./ButtonBase-1.0.74-W6tAH7AI.js";import"./useEnhancedEffect-1.0.74-B56M26dS.js";import"./Select-1.0.74-DHOnlEEH.js";import"./Menu-1.0.74-CdjCBJ4R.js";import"./ThemeProvider-1.0.74-4uzbYYLM.js";import"./index-1.0.74-DxwH6OqZ.js";import"./Portal-1.0.74-BrUPeMX9.js";import"./iconBase-1.0.74-Cs0vntJu.js";import"./isHostComponent-1.0.74-DVu5iVWx.js";import"./Modal-1.0.74-BfLid1bk.js";import"./createSvgIcon-1.0.74-Cw_ZFbxi.js";import"./SwitchBase-1.0.74-pUYMwK3f.js";const G=({columnName:t,columnValue:o,columnMetaData:p,onColumnChange:u,formMode:i,metaData:d,storeColumn:a})=>{b.debug(t,o,p);let r={label:"",url:"",target:""};try{o!==null&&o!==""&&(r=JSON.parse(o),r!=null&&(r.label===void 0||r.url===void 0||r.target===void 0)&&(r={label:(r==null?void 0:r.label)??"",url:(r==null?void 0:r.url)??"",target:(r==null?void 0:r.target)??""}))}catch(l){console.error(l),console.error(o)}b.debug(r);const n=l=>{u(t,JSON.stringify({...r,...l}))};return e.jsxs("fieldset",{className:"pp-fieldset",children:[e.jsx("legend",{children:p.formLabel}),r!==void 0?e.jsxs(g,{style:{display:"grid",gridTemplateColumns:"1fr auto",alignItems:"center",gap:"20px"},children:[e.jsx(x,{label:"Label",value:(r==null?void 0:r.label)??"",required:p.is_nullable==="NO",slotProps:{input:{readOnly:i===s.VIEW||i===s.UPDATE&&(d.primary_key.includes(t)||a.updatable===!1)}},onChange:l=>{n({label:l.target.value})}}),e.jsx(m,{sx:{"& label span":{fontSize:"80% !important"}},children:e.jsx(v,{control:e.jsx(E,{id:t,checked:(r==null?void 0:r.target)==="_blank",disabled:i===s.VIEW||i===s.UPDATE&&(d.primary_key.includes(t)||a.updatable===!1),onChange:(l,f)=>{n({target:f?"_blank":""})}}),label:"Open link in a new tab"})}),e.jsx(x,{label:"Url",value:(r==null?void 0:r.url)??"",required:p.is_nullable==="NO",slotProps:{input:{readOnly:i===s.VIEW||i===s.UPDATE&&(d.primary_key.includes(t)||a.updatable===!1)}},sx:{gridColumn:"1 / span 2"},onChange:l=>{n({url:l.target.value})}}),a.hint&&a.hint.trim()!==""&&e.jsx(m,{children:e.jsx(j,{sx:{marginLeft:0},children:c(a,"")})})]}):e.jsx(g,{color:"error.main",className:"unselectable",children:"Invalid hyperlink"})]})};export{G as default};
