import{$ as e,C as t,D as n,E as r,I as i,J as a,L as o,N as s,O as c,S as ee,U as l,V as te,W as u,X as d,Z as f,_ as ne,d as p,et as m,i as h,m as re,p as ie,r as ae,u as oe,v as g,w as _,x as v}from"./app-QN0AU_xH.js";import{t as y}from"./i18n-Q2D3wWEQ.js";import{n as b}from"./toast-BtdhoA-d.js";import{t as x}from"./AdminLayout-CZ2d25FZ.js";var S={key:0},C={class:`mb-4`},w={key:0,class:`overflow-hidden rounded-2xl border border-line bg-appbg`},T=[`src`,`title`],E={key:1,class:`max-w-2xl space-y-5`},D={class:`rounded-2xl border border-line bg-surface p-5`},O={class:`flex items-start gap-3`},k={class:`min-w-0 flex-1`},A={class:`text-sm text-ink-2`},j={class:`mt-2 flex items-center gap-2`},M={class:`text-[11px] text-ink-muted`},N={key:0,class:`flex items-center gap-3`},P=[`onUpdate:modelValue`],se={class:`text-sm font-medium text-ink`},F={class:`block text-sm font-medium text-ink-2`},I=[`onUpdate:modelValue`],L=[`onUpdate:modelValue`],R=[`value`],z=[`type`,`onUpdate:modelValue`],B={key:2,class:`mt-1 text-xs text-ink-muted`},V={class:`flex items-center gap-2 pt-1 text-sm`},H={key:0,class:`text-ink-muted`},U={key:1,class:`font-semibold text-emerald-500`},W={key:2,class:`text-red-500`},G={key:3,class:`text-ink-muted`},K={key:1,class:`rounded-2xl border border-dashed border-line p-8 text-center text-sm text-ink-muted`},q=c({__name:`ExtensionSettings`,props:{ext:{}},setup(c){let q=c,J=a({...q.ext.values}),Y=a(`idle`),X=null;function Z(){Y.value=`saving`,m.post(`/admin/marketplace/settings`,{id:q.ext.id,values:J.value},{preserveScroll:!0,preserveState:!0,only:[],onSuccess:()=>{Y.value=`saved`,b(y(`Settings saved`)),setTimeout(()=>{Y.value===`saved`&&(Y.value=`idle`)},2e3)},onError:()=>{Y.value=`error`,b(y(`Couldn't save — will retry`),`error`)}})}te(J,()=>{X&&clearTimeout(X),Y.value=`saving`,X=setTimeout(Z,700)},{deep:!0});let Q=a(null),$=null;function ce(){let e=Q.value;if(e)try{let t=e.contentDocument;if(!t)return;let n=getComputedStyle(document.documentElement),r=e=>n.getPropertyValue(e).trim(),i=(document.documentElement.dataset.theme||document.body.dataset.theme)===`dark`,a=t.createElement(`style`);a.textContent=`
      :root{
        --c-bg:${r(`--c-bg`)};--c-surface:${r(`--c-surface`)};--c-surface-2:${r(`--c-surface-2`)};
        --c-border:${r(`--c-border`)};--c-text:${r(`--c-text`)};--c-text-2:${r(`--c-text-2`)};
        --c-muted:${r(`--c-muted`)};--c-primary:${r(`--c-primary`)};
        color-scheme:${i?`dark`:`light`};
      }
      .top{display:none!important}
      a[href="/admin/marketplace"]{display:none!important}
      .wrap,.container{max-width:none!important;margin:0!important;padding:18px 20px!important}
      html,body{background:transparent!important;color:rgb(var(--c-text))!important;min-height:0!important}
      h1,h2,h3,h4{color:rgb(var(--c-text))!important}
      .card,.panel,.box,.stat,.tile,.well{background:rgb(var(--c-surface))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .sub,.hint,.muted,.meta,.note{color:rgb(var(--c-muted))!important}
      label,.f,.chk,.lbl,legend,th{color:rgb(var(--c-text-2))!important}
      input:not([type=checkbox]):not([type=radio]),textarea,select{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .toggle,.switch,.option-row,.field-row,.input-row{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      a:not(.btn){color:rgb(var(--c-primary))!important}
      .btn.ghost{border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text-2))!important}
      table,th,td,hr,.row,.item,.divider{border-color:rgb(var(--c-border))!important}
      ::-webkit-scrollbar{width:0;height:0}
    `,t.head.appendChild(a);let o=!!t.querySelector(`.top, .wrap, .container`),s=()=>{try{e.style.height=(t.documentElement.scrollHeight||t.body.scrollHeight)+`px`}catch{}};o?(e.style.minHeight=`0`,s(),t.body&&($=new ResizeObserver(s),$.observe(t.body))):e.style.minHeight=`78vh`}catch{e.style.minHeight=`78vh`}}return s(()=>{$?.disconnect(),$=null}),(a,s)=>(i(),ee(x,null,{title:l(()=>[r(e(c.ext.name),1)]),subtitle:l(()=>[r(e(c.ext.type===`theme`?d(y)(`Theme`):d(y)(`Extension`))+` · v`+e(c.ext.version),1),c.ext.author?(i(),_(`span`,S,` · `+e(d(y)(`by {author}`,{author:c.ext.author})),1)):t(``,!0)]),default:l(()=>[n(d(ae),{title:`${c.ext.name}`},null,8,[`title`]),v(`div`,C,[n(d(h),{href:`/admin/marketplace`,class:`inline-flex items-center gap-1.5 text-sm font-semibold text-ink-2 hover:text-ink`},{default:l(()=>[s[0]||=v(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[v(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})],-1),r(` `+e(d(y)(`Marketplace`)),1)]),_:1})]),c.ext.adminUrl?(i(),_(`div`,w,[v(`iframe`,{ref_key:`frame`,ref:Q,src:c.ext.adminUrl+(c.ext.adminUrl.includes(`?`)?`&`:`?`)+`embed=1`,title:d(y)(`Extension settings`),class:`block w-full border-0`,style:{"min-height":`60vh`},onLoad:ce},null,40,T)])):(i(),_(`div`,E,[v(`div`,D,[v(`div`,O,[v(`div`,{class:f([`grid h-11 w-11 shrink-0 place-items-center rounded-xl text-lg`,c.ext.type===`theme`?`bg-fuchsia-500/15 text-fuchsia-300`:`bg-indigo-500/15 text-indigo-300`])},e(c.ext.type===`theme`?`🎨`:`🧩`),3),v(`div`,k,[v(`p`,A,e(c.ext.description),1),v(`div`,j,[v(`span`,{class:f([`rounded px-1.5 py-0.5 text-[11px] font-semibold`,c.ext.enabled?`bg-emerald-500/15 text-emerald-300`:`bg-surface-2 text-ink-2`])},e(c.ext.enabled?d(y)(`Enabled`):d(y)(`Disabled`)),3),v(`span`,M,e(c.ext.id),1)])])])]),c.ext.settings.length?(i(),_(`form`,{key:0,class:`rounded-2xl border border-line bg-surface p-5 space-y-4`,onSubmit:ne(Z,[`prevent`])},[(i(!0),_(g,null,o(c.ext.settings,n=>(i(),_(`div`,{key:n.key},[n.type===`boolean`?(i(),_(`label`,N,[u(v(`input`,{type:`checkbox`,"onUpdate:modelValue":e=>J.value[n.key]=e,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,8,P),[[oe,J.value[n.key]]]),v(`span`,se,e(n.label),1)])):(i(),_(g,{key:1},[v(`label`,F,e(n.label),1),n.type===`textarea`?u((i(),_(`textarea`,{key:0,"onUpdate:modelValue":e=>J.value[n.key]=e,rows:`3`,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,8,I)),[[re,J.value[n.key]]]):n.type===`select`?u((i(),_(`select`,{key:1,"onUpdate:modelValue":e=>J.value[n.key]=e,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},[(i(!0),_(g,null,o(n.options||[],t=>(i(),_(`option`,{key:t.value,value:t.value},e(t.label),9,R))),128))],8,L)),[[ie,J.value[n.key]]]):u((i(),_(`input`,{key:2,type:n.type===`number`?`number`:n.type===`color`?`color`:`text`,"onUpdate:modelValue":e=>J.value[n.key]=e,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,8,z)),[[p,J.value[n.key]]])],64)),n.help?(i(),_(`p`,B,e(n.help),1)):t(``,!0)]))),128)),v(`div`,V,[Y.value===`saving`?(i(),_(`span`,H,e(d(y)(`Saving…`)),1)):Y.value===`saved`?(i(),_(`span`,U,e(d(y)(`✓ All changes saved`)),1)):Y.value===`error`?(i(),_(`span`,W,e(d(y)(`Couldn't save — will retry on next change`)),1)):(i(),_(`span`,G,e(d(y)(`Changes save automatically`)),1))])],32)):(i(),_(`p`,K,e(d(y)(`This {type} has no configurable settings.`,{type:c.ext.type})),1))]))]),_:1}))}});export{q as default};