/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{computed as e,unref as o,reactive as r,openBlock as s,createElementBlock as t,normalizeClass as l,createVNode as d,normalizeStyle as a,isRef as i,createElementVNode as n,withCtx as c,createTextVNode as m,toDisplayString as u}from"vue";import{useClipboard as p}from"../../node_modules/@vueuse/core/dist/index.js";import{Codemirror as g}from"../../node_modules/vue-codemirror/dist/vue-codemirror.esm.js";import{oneDark as f}from"../../node_modules/@codemirror/theme-one-dark/dist/index.js";import{json as j,jsonParseLinter as h}from"../../node_modules/@codemirror/lang-json/dist/index.js";import{java as x}from"../../node_modules/@codemirror/lang-java/dist/index.js";import{sql as y}from"../../node_modules/@codemirror/lang-sql/dist/index.js";import{javascript as v}from"../../node_modules/@codemirror/lang-javascript/dist/index.js";import{yaml as _}from"../../node_modules/@codemirror/lang-yaml/dist/index.js";import{xml as b}from"../../node_modules/@codemirror/lang-xml/dist/index.js";import{python as k}from"../../node_modules/@codemirror/lang-python/dist/index.js";import{linter as S,lintGutter as E}from"../../node_modules/@codemirror/lint/dist/index.js";import{useModelBinding as V}from"@gsc-basic/hooks";import{useNamespace as B}from"../../hooks/useNamespace.js";import{useLocale as C}from"../../hooks/useLocale.js";import{GscButton as O}from"../../Button/index.js";import './index3.css';import './index2.css';import './index.css';/* empty css          *//* empty css          *//* empty css          */import q from"../../_virtual/_plugin-vue_export-helper.js";const D={class:"flex items-center justify-between py-1 text-xs dark:text-gray-200 dark:bg-gray-800"},N={class:"flex"},T={class:"pr-2"},w={class:"pr-2"},J={class:"pr-2"},U=/* @__PURE__ */q(/* @__PURE__ */Object.assign({name:"GscCodeEditor"},{__name:"index",props:{modelValue:{type:[String]},placeholder:{type:String},editorStyle:{type:[Array,String,Object],default:()=>({height:"180px"})},language:{type:String,default:"json",validator:e=>["json","java","sql","yaml","xml","python","javascript"].includes(e)},isDarkTheme:Boolean,disabled:Boolean,readonly:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1}},emits:["change","update:modelValue"],setup(q){const U=q,{prefixCls:z}=B("code-editor"),{t:A}=C(),G={json:()=>U.readonly?[j()]:[j(),S(h()),E()],java:()=>[x()],sql:()=>[y()],yaml:()=>[_()],xml:()=>[b()],python:()=>[k()],javascript:()=>[v({jsx:!0,typescript:!0})]},I=e(()=>{const e=[...G[U.language]?.()??[]];return U.isDarkTheme&&e.push(f),e}),L=e(()=>{if(U.placeholder)return U.placeholder;const e=`gsc.codeEditor.placeholder.${U.language}`,o=A(e);return o===e?A("gsc.codeEditor.placeholder.default"):o}),[$,F]=V(U,"modelValue","update:modelValue");try{"json"===U.language&&F(JSON.stringify(JSON.parse(o($)),null,2))}catch{}const H=e(()=>{const e=o($);return!e||0===e.length}),{copy:K,copied:M,isSupported:P}=p({source:$,legacy:!0}),Q=e(()=>!P.value||H.value),R=e(()=>A(M.value?"gsc.codeEditor.action.copied":"gsc.codeEditor.action.copy")),W=()=>{Q.value||K()},X=r({lines:null,cursor:null,length:null}),Y=e=>{const o=e.state.selection.ranges;X.cursor=o[0].anchor,X.length=e.state.doc.length,X.lines=e.state.doc.lines};return(e,r)=>(s(),t("div",{class:l([o(z),q.isDarkTheme?"dark-bg":"light-bg"])},[d(o(g),{modelValue:o($),"onUpdate:modelValue":r[0]||(r[0]=e=>i($)?$.value=e:null),placeholder:L.value,style:a(q.editorStyle),autofocus:q.autofocus,"indent-with-tab":!0,"tab-size":2,disabled:q.disabled,extensions:I.value,onUpdate:Y},null,8,["modelValue","placeholder","style","autofocus","disabled","extensions"]),n("div",D,[d(o(O),{variant:"text",disabled:Q.value,onClick:W},{default:c(()=>[r[1]||(r[1]=n("i",{class:"i-material-symbols:content-copy-outline"},null,-1)),m(" "+u(R.value),1)]),_:1},8,["disabled"]),n("div",N,[n("span",T,u(o(A)("gsc.codeEditor.info.length"))+": "+u(X.length),1),n("span",w,u(o(A)("gsc.codeEditor.info.lines"))+": "+u(X.lines),1),n("span",J,u(o(A)("gsc.codeEditor.info.cursor"))+": "+u(X.cursor),1)])])],2))}}),[["__scopeId","data-v-ce63579c"]]);export{U as default};