import{$ as e,B as t,C as n,D as r,E as i,F as a,H as o,I as s,M as ee,Q as c,S as l,T as u,U as d,X as f,Y as p,_ as m,b as h,f as te,g,l as _,n as ne,p as re,q as v,r as ie,u as ae,x as oe}from"./app-IEG2AoVo.js";import{t as y}from"./i18n-DaAXEKDB.js";import{n as b}from"./toast-Hy9nQzUw.js";import{t as x}from"./AdminLayout-C0Gudov1.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`],F={class:`text-sm font-medium text-ink`},se={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=r({__name:`ExtensionSettings`,props:{ext:{}},setup(r){let q=r,J=v({...q.ext.values}),Y=v(`idle`),X=null;function Z(){Y.value=`saving`,e.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`)}})}t(J,()=>{X&&clearTimeout(X),Y.value=`saving`,X=setTimeout(Z,700)},{deep:!0});let Q=v(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 ee(()=>{$?.disconnect(),$=null}),(e,t)=>(a(),oe(x,null,{title:o(()=>[u(c(r.ext.name),1)]),subtitle:o(()=>[u(c(r.ext.type===`theme`?p(y)(`Theme`):p(y)(`Extension`))+` · v`+c(r.ext.version),1),r.ext.author?(a(),n(`span`,S,` · `+c(p(y)(`by {author}`,{author:r.ext.author})),1)):l(``,!0)]),default:o(()=>[i(p(ne),{title:`${r.ext.name}`},null,8,[`title`]),h(`div`,C,[i(p(ie),{href:`/admin/marketplace`,class:`inline-flex items-center gap-1.5 text-sm font-semibold text-ink-2 hover:text-ink`},{default:o(()=>[t[0]||=h(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[h(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})],-1),u(` `+c(p(y)(`Marketplace`)),1)]),_:1})]),r.ext.adminUrl?(a(),n(`div`,w,[h(`iframe`,{ref_key:`frame`,ref:Q,src:r.ext.adminUrl+(r.ext.adminUrl.includes(`?`)?`&`:`?`)+`embed=1`,title:p(y)(`Extension settings`),class:`block w-full border-0`,style:{"min-height":`60vh`},onLoad:ce},null,40,T)])):(a(),n(`div`,E,[h(`div`,D,[h(`div`,O,[h(`div`,{class:f([`grid h-11 w-11 shrink-0 place-items-center rounded-xl text-lg`,r.ext.type===`theme`?`bg-fuchsia-500/15 text-fuchsia-300`:`bg-indigo-500/15 text-indigo-300`])},c(r.ext.type===`theme`?`🎨`:`🧩`),3),h(`div`,k,[h(`p`,A,c(r.ext.description),1),h(`div`,j,[h(`span`,{class:f([`rounded px-1.5 py-0.5 text-[11px] font-semibold`,r.ext.enabled?`bg-emerald-500/15 text-emerald-300`:`bg-surface-2 text-ink-2`])},c(r.ext.enabled?p(y)(`Enabled`):p(y)(`Disabled`)),3),h(`span`,M,c(r.ext.id),1)])])])]),r.ext.settings.length?(a(),n(`form`,{key:0,class:`rounded-2xl border border-line bg-surface p-5 space-y-4`,onSubmit:g(Z,[`prevent`])},[(a(!0),n(m,null,s(r.ext.settings,e=>(a(),n(`div`,{key:e.key},[e.type===`boolean`?(a(),n(`label`,N,[d(h(`input`,{type:`checkbox`,"onUpdate:modelValue":t=>J.value[e.key]=t,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,8,P),[[_,J.value[e.key]]]),h(`span`,F,c(e.label),1)])):(a(),n(m,{key:1},[h(`label`,se,c(e.label),1),e.type===`textarea`?d((a(),n(`textarea`,{key:0,"onUpdate:modelValue":t=>J.value[e.key]=t,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[e.key]]]):e.type===`select`?d((a(),n(`select`,{key:1,"onUpdate:modelValue":t=>J.value[e.key]=t,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},[(a(!0),n(m,null,s(e.options||[],e=>(a(),n(`option`,{key:e.value,value:e.value},c(e.label),9,R))),128))],8,L)),[[te,J.value[e.key]]]):d((a(),n(`input`,{key:2,type:e.type===`number`?`number`:e.type===`color`?`color`:`text`,"onUpdate:modelValue":t=>J.value[e.key]=t,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)),[[ae,J.value[e.key]]])],64)),e.help?(a(),n(`p`,B,c(e.help),1)):l(``,!0)]))),128)),h(`div`,V,[Y.value===`saving`?(a(),n(`span`,H,c(p(y)(`Saving…`)),1)):Y.value===`saved`?(a(),n(`span`,U,c(p(y)(`✓ All changes saved`)),1)):Y.value===`error`?(a(),n(`span`,W,c(p(y)(`Couldn't save — will retry on next change`)),1)):(a(),n(`span`,G,c(p(y)(`Changes save automatically`)),1))])],32)):(a(),n(`p`,K,c(p(y)(`This {type} has no configurable settings.`,{type:r.ext.type})),1))]))]),_:1}))}});export{q as default};