var t=Object.defineProperty,e=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,a=(e,r,o)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,c=(t,e)=>{for(var r in e||(e={}))i.call(e,r)&&a(t,r,e[r]);if(o)for(var r of o(e))n.call(e,r)&&a(t,r,e[r]);return t};import{C as s,f as p,i as l,M as d}from"./importFormatHelper.b3b79738.js";import{s as m,a as g,C as h,d as u,u as b,b as x,F as f,j as y,R as k}from"./vendor.6729457a.js";const E=m.button`
  display: inline-flex;
  align-items: center;
  color: ${s.LIGHT_RED} !important;
  background: ${s.WHITE} !important;
  border-radius: 4px;
  border: 2px solid ${s.LIGHT_RED};
  margin: 0 12px 0 0;
  padding: 0 8px;
  font-weight: 600;
  height: 35px;
  cursor: pointer;
  box-shadow: none !important;
  text-shadow: none !important;

  img {
    margin-right: 2px;
  }

  &:last-of-type {
    margin-right: 0;
  }

  &:focus {
    border-color: ${s.LIGHT_RED} !important;
  }

  &:hover {
    background-image: none !important;
    color: ${g(.12,s.LIGHT_RED)} !important;
    border-color: ${g(.12,s.LIGHT_RED)} !important;
  }

  ${t=>t.primary&&h`
    background: ${s.LIGHT_RED} !important;
    color: ${s.WHITE} !important;

    &:hover {
      background-image: none !important;
      background: ${g(.05,s.LIGHT_RED)} !important;
      color: ${s.WHITE} !important;
      border-color: ${g(.05,s.LIGHT_RED)} !important;
    }
  `}
`,I=m.div`
  position: relative;
  display: flex;
  border: 1px solid ${s.LIGHT_GRAY};
  padding: 20px 16px;
  border-radius: 3px;
  margin-top: 16px;

  &:first-of-type {
    margin-top: 8px;
  }

  ${t=>h`
    &::after {
      position: absolute;
      content: '${t.desc}';
      color: ${s.LIGHT_GRAY};
      padding: 0 8px;
      background: white;
      left: 12px;
      top: -10px;
      font-size: 14px;
      font-weight: 600;
    }
  `}
`,$=m.label`
  display: inline-block;
  margin-right: 20px;
  color: ${s.DARK};

  input {
    margin-right: 5px !important;
  }

  &:last-of-type {
    margin-right: 0;
  }
`,v=m.section`
  padding: 10px;
`,T=m.div`
  pointer-events: none;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.75);

  .drop-mask-line {
    width: calc(100% - 30px);
    height: calc(100% - 30px);
    display: flex;
    border: 2px dashed ${s.YALLOW};
    justify-content: center;
    align-items: center;
    border-radius: 20px;
  }
`,R=({id:t,label:e,checked:r})=>{const[o,i]=u.exports.useState(r),n=u.exports.useCallback((t=>{i(t.target.checked)}),[i]);return[o,y($,{htmlFor:t,children:[x("input",{id:t,checked:o,type:"checkbox",onChange:n}),e]})]},S=({setting:t,onSave:o,onImportScripts:i,onExportScripts:n})=>{const[a,s]=R({id:"dark",label:"Dark Theme",checked:t.dark}),[d,m]=R({id:"notice",label:"Execution Notice",checked:t.notice}),[g,h]=u.exports.useState(""),k=u.exports.useCallback((async t=>{const e=await p(t).catch((()=>{h("error")}));if(!Array.isArray(e))return;const r=l(e);h("success"),i(r)}),[i]),{getRootProps:$,getInputProps:S,open:w,isDragActive:H}=b({onDrop:k,noClick:!0,noKeyboard:!0}),D=u.exports.useMemo((()=>H?x(T,{children:x("div",{className:"drop-mask-line",children:x("img",{width:"40",height:"40",alt:"",src:"../imgs/drop.svg"})})}):x(f,{})),[H]);return u.exports.useEffect((()=>{o({dark:a,notice:d})}),[a,d,o]),y(v,(G=c({},$()),L={children:[y(I,{desc:"Setting",children:[s,m]}),y(I,{desc:"Scripts",children:[x("input",c({},S())),y(E,{type:"button",primary:!0,onClick:w,children:[""===g?null:x("img",{width:"25",height:"25",alt:g,src:`../imgs/${g}.svg`}),x("span",{children:"Import Scripts"})]}),x(E,{type:"button",onClick:n,children:"Export Scripts"})]}),D]},e(G,r(L))));var G,L};S.defaultProps={};let w={dark:!0,notice:!1};function H(t){w=c(c({},w),t),chrome.storage&&chrome.storage.local.set({setting:w})}function D(t){chrome.storage&&chrome.storage.local.set({scripts:t})}function G(){chrome.runtime&&chrome.runtime.sendMessage({type:d.EXPORT_SCRIPTS},(()=>{chrome.runtime.lastError&&console.log("lastError:",chrome.runtime.lastError)}))}function L(t){k.render(x(S,{setting:t,onSave:H,onImportScripts:D,onExportScripts:G}),document.getElementById("root"))}chrome.storage?chrome.storage.local.get(["setting"],(t=>{const{setting:e}=t;e&&"boolean"==typeof e.dark&&(w.dark=e.dark),e&&"boolean"==typeof e.notice&&(w.notice=e.notice),L(w)})):L(w);
