"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react");exports.default=function(r){var o=r.isOpen,s=r.onClose,a=r.onSave,l=r.initialName,d=void 0===l?"":l,c=t.useState(d),u=c[0],p=c[1],x=t.useState(""),f=x[0],g=x[1],b=t.useState(!1),y=b[0],_=b[1],h=t.useRef(null);if(t.useEffect(function(){o&&(p(d),g(""),setTimeout(function(){var e,n;null===(e=h.current)||void 0===e||e.focus(),null===(n=h.current)||void 0===n||n.select()},50))},[o,d]),!o)return null;var v=function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,t;return e.__generator(this,function(e){switch(e.label){case 0:if(!u.trim())return g("Scope Name is required"),[2];g(""),_(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a(u.trim())];case 2:return e.sent(),s(),[3,5];case 3:return n=e.sent(),409===(null==(t=n)?void 0:t.status)?g("Scope name already exists."):g("Failed to rename scope. Please try again."),[3,5];case 4:return _(!1),[7];case 5:return[2]}})})};return n.jsx("div",e.__assign({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&s()}},{children:n.jsxs("div",e.__assign({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[n.jsx("span",e.__assign({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),n.jsx("button",e.__assign({onClick:s,disabled:y,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:n.jsx(i.X,{size:20})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[n.jsxs("label",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),n.jsx("input",{ref:h,type:"text",value:u,onChange:function(e){p(e.target.value),f&&g("")},onKeyDown:function(e){"Enter"===e.key&&v(),"Escape"===e.key&&s()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(f?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),f&&n.jsx("p",e.__assign({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:f}))]})),n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[n.jsx("button",e.__assign({onClick:s,disabled:y,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.6:1}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:v,disabled:y,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.7:1}},{children:y?"Saving...":"Save"}))]}))]}))}))};
//# sourceMappingURL=RenameScopeModal.js.map
