*/var U0;function Hm(){if(U0)return et;U0=1;var c=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),T=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),w=Symbol.iterator;function C(y){return y===null||typeof y!="object"?null:(y=w&&y[w]||y["@@iterator"],typeof y=="function"?y:null)}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H=Object.assign,G={};function Q(y,U,V){this.props=y,this.context=U,this.refs=G,this.updater=V||B}Q.prototype.isReactComponent={},Q.prototype.setState=function(y,U){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,U,"setState")},Q.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function L(){}L.prototype=Q.prototype;function Y(y,U,V){this.props=y,this.context=U,this.refs=G,this.updater=V||B}var $=Y.prototype=new L;$.constructor=Y,H($,Q.prototype),$.isPureReactComponent=!0;var it=Array.isArray,I={H:null,A:null,T:null,S:null,V:null},zt=Object.prototype.hasOwnProperty;function Rt(y,U,V,j,J,ft){return V=ft.ref,{$$typeof:c,type:y,key:U,ref:V!==void 0?V:null,props:ft}}function _t(y,U){return Rt(y.type,U,void 0,void 0,void 0,y.props)}function St(y){return typeof y=="object"&&y!==null&&y.$$typeof===c}function Jt(y){var U={"=":"=0",":":"=2"};return"$"+y.replace(/[=:]/g,function(V){returnU[V]})}varoe=/\/+/g;functionVt(y,U){returntypeofy=="object"&&y!==null&&y.key!=null?Jt(""+y.key):U.toString(36)}functionEl(){}functionTl(y){switch(y.status){case"fulfilled":returny.value;case"rejected":throwy.reason;default:switch(typeofy.status=="string"?y.then(El,El):(y.status="pending",y.then(function(U){y.status==="pending"&&(y.status="fulfilled",y.value=U)},function(U){y.status==="pending"&&(y.status="rejected",y.reason=U)})),y.status){case"fulfilled":returny.value;case"rejected":throwy.reason}}throwy}functionXt(y,U,V,j,J){varft=typeofy;(ft==="undefined"||ft==="boolean")&&(y=null);vartt=!1;if(y===null)tt=!0;elseswitch(ft){case"bigint":case"string":case"number":tt=!0;break;case"object":switch(y.$$typeof){casec:caseo:tt=!0;break;caseR:returntt=y._init,Xt(tt(y._payload),U,V,j,J)}}if(tt)returnJ=J(y),tt=j===""?"."+Vt(y,0):j,it(J)?(V="",tt!=null&&(V=tt.replace(oe,"$&/")+"/"),Xt(J,U,V,"",function($e){return$e})):J!=null&&(St(J)&&(J=_t(J,V+(J.key==null||y&&y.key===J.key?"":(""+J.key).replace(oe,"$&/")+"/")+tt)),U.push(J)),1;tt=0;varte=j===""?".":j+":";if(it(y))for(varbt=0;bt<y.length;bt++)j=y[bt],ft=te+Vt(j,bt),tt+=Xt(j,U,V,ft,J);elseif(bt=C(y),typeofbt=="function")for(y=bt.call(y),bt=0;!(j=y.next()).done;)j=j.value,ft=te+Vt(j,bt++),tt+=Xt(j,U,V,ft,J);elseif(ft==="object"){if(typeofy.then=="function")returnXt(Tl(y),U,V,j,J);throwU=String(y),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(y).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}returntt}functionM(y,U,V){if(y==null)returny;varj=[],J=0;returnXt(y,j,"","",function(ft){returnU.call(V,ft,J++)}),j}functionq(y){if(y._status===-1){varU=y._result;U=U(),U.then(function(V){(y._status===0||y._status===-1)&&(y._status=1,y._result=V)},function(V){(y._status===0||y._status===-1)&&(y._status=2,y._result=V)}),y._status===-1&&(y._status=0,y._result=U)}if(y._status===1)returny._result.default;throwy._result}varF=typeofreportError=="function"?reportError:function(y){if(typeofwindow=="object"&&typeofwindow.ErrorEvent=="function"){varU=newwindow.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeofy=="object"&&y!==null&&typeofy.message=="string"?String(y.message):String(y),error:y});if(!window.dispatchEvent(
Pleasechangetheparent<Routepath="${Y}">to<Routepath="${Y==="/"?"*":`${Y}/*`}">.`)}let w=bl(),C;if(o){let Y=typeof o=="string"?Gl(o):o;Tt(d==="/"||((L=Y.pathname)==null?void 0:L.startsWith(d)),`Whenoverridingthelocationusing\`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${Y.pathname}" was given in the \`location\` prop.`),C=Y}elseC=w;letB=C.pathname||"/",H=B;if(d!=="/"){letY=d.replace(/^\//,"").split("/");H="/"+B.replace(/^\//,"").split("/").slice(Y.length).join("/")}letG=$0(c,{pathname:H});be(R||G!=null,`No routes matched location "${C.pathname}${C.search}${C.hash}" `),be(G==null||G[G.length-1].route.element!==void0||G[G.length-1].route.Component!==void0||G[G.length-1].route.lazy!==void0,`Matched leaf route at location "${C.pathname}${C.search}${C.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);letQ=x1(G&&G.map(Y=>Object.assign({},Y,{params:Object.assign({},D,Y.params),pathname:Je([d,h.encodeLocation?h.encodeLocation(Y.pathname).pathname:Y.pathname]),pathnameBase:Y.pathnameBase==="/"?d:Je([d,h.encodeLocation?h.encodeLocation(Y.pathnameBase).pathname:Y.pathnameBase])})),v,s,r);returno&&Q?_.createElement(Nu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...C},navigationType:"POP"}},Q):Q}functionS1(){letc=O1(),o=d1(c)?`${c.status}${c.statusText}`:cinstanceofError?c.message:JSON.stringify(c),s=cinstanceofError?c.stack:null,r="rgba(200,200,200, 0.5)",h={padding:"0.5rem",backgroundColor:r},v={padding:"2px 4px",backgroundColor:r},T=null;returnconsole.error("Error handled by React Router default ErrorBoundary:",c),T=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:v},"ErrorBoundary")," or"," ",_.createElement("code",{style:v},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},o),s?_.createElement("pre",{style:h},s):null,T)}varb1=_.createElement(S1,null),E1=classextends_.Component{constructor(c){super(c),this.state={location:c.location,revalidation:c.revalidation,error:c.error}}staticgetDerivedStateFromError(c){return{error:c}}staticgetDerivedStateFromProps(c,o){returno.location!==c.location||o.revalidation!=="idle"&&c.revalidation==="idle"?{error:c.error,location:c.location,revalidation:c.revalidation}:{error:c.error!==void0?c.error:o.error,location:o.location,revalidation:c.revalidation||o.revalidation}}componentDidCatch(c,o){console.error("React Router caught the following error during render",c,o)}render(){returnthis.state.error!==void0?_.createElement(Ce.Provider,{value:this.props.routeContext},_.createElement(Nf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};functionT1({routeContext:c,match:o,children:s}){letr=_.useContext(Oa);returnr&&r.static&&r.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=o.route.id),_.createElement(Ce.Provider,{value:c},s)}functionx1(c,o=[],s=null,r=null){if(c==null){if(!s)returnnull;if(s.errors)c=s.matches;elseif(o.length===0&&!s.initialized&&s.matches.length>0)c=s.matches;elsereturnnull}leth=c,v=s==null?void0:s.errors;if(v!=null){letp=h.findIndex(d=>d.route.id&&(v==null?void0:v[d.route.id])!==void0);Tt(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(v).join(",")}`),h=h.slice(0,Math.min(h.length,p+1))}letT=!1,D=-1;if(s)for(letp=0;p<h.length;p++){letd=h[p];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(D=p),d.route.id){let{loaderData:R,errors:w}=s,C=d.route.loader&&!R.hasOwnProperty(d.route.id)&
`):Z.jsx("span",{className:"text-gray-400",children:"None"})})]})}function k0({onConfigSaved:c}){const[o,s]=_.useState(""),[r,h]=_.useState(null),[v,T]=_.useState(null),[D,p]=_.useState(null),[d,R]=_.useState(!1),w=Uf();_.useEffect(()=>{chrome.storage.local.get("cdrm_instance",B=>{chrome.runtime.lastError?console.error("Error fetching CDRM instance:",chrome.runtime.lastError):B.cdrm_instance&&h(B.cdrm_instance)})},[]);const C=async()=>{const B=o.trim().replace(/\/+$/,"");if(!B){T("Please enter a valid URL."),p("error");return}const H=B+"/api/extension";R(!0),T(null);try{if((await(await fetch(H,{method:"POST",headers:{"Content-Type":"application/json"}})).json()).status===!0){T("Successfully connected to CDRM Instance."),p("success");const L=await fetch(`${B}/remotecdm/widevine/deviceinfo`);if(!L.ok)throw new Error("Failed to fetch Widevine device info");const Y=await L.json(),$=await fetch(`${B}/remotecdm/playready/deviceinfo`);if(!$.ok)throw new Error("Failed to fetch PlayReady device info");const it=await $.json();chrome.storage.local.set({valid_config:!0,cdrm_instance:B,widevine_device:{device_type:Y.device_type,system_id:Y.system_id,security_level:Y.security_level,secret:Y.secret,device_name:Y.device_name,host:B},playready_device:{security_level:it.security_level,secret:it.secret,device_name:it.device_name,host:B}},()=>{chrome.runtime.lastError?(console.error("Error saving to chrome.storage:",chrome.runtime.lastError),T("Error saving configuration."),p("error")):(console.log("Configuration saved."),h(B),s(""),c&&c(),w("/results"))})}else throw new Error("Invalid response from endpoint.")}catch(G){console.error("Connection error:",G),T("Invalid endpoint or device info could not be retrieved."),p("error")}finally{R(!1)}};return Z.jsxs("div",{className:"w-full h-full overflow-y-auto overflow-x-auto flex flex-col p-4",children:[Z.jsx("input",{type:"text",value:o,onChange:B=>s(B.target.value),placeholder:r?`CurrentCDRMInstance:${r}`:"CDRM Instance URL (e.g., https://cdrm-project.com/, http://127.0.0.1:5000/)",className:"w-full p-4 text-lg bg-gray-800 text-white border border-gray-700 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 mt-4"}),Z.jsx("button",{onClick:C,disabled:d,className:`mt-4p-2${d?"bg-blue-400":"bg-blue-600 hover:bg-blue-700"}text-whiterounded-mdtransitionduration-300`,children:d?"Connecting...":"Save Settings"}),v&&Z.jsx("p",{className:`mt-2text-smtext-center${D==="success"?"text-green-400":"text-red-400"}`,children:v})]})}function p2(){const[c,o]=_.useState(!1),[s,r]=_.useState(null);return _.useEffect(()=>{chrome.storage.local.get("valid_config",h=>{chrome.runtime.lastError?(console.error("Error reading valid_config:",chrome.runtime.lastError),r(!1)):r(h.valid_config===!0)})},[]),s===null?Z.jsx("div",{className:"flex items-center justify-center h-screen bg-black text-white",children:"Loading..."}):Z.jsx(l2,{children:Z.jsxs("div",{className:"min-w-full min-h-full w-full h-full flex flex-grow bg-black/95 flex-col relative",children:[Z.jsx("div",{className:"w-full min-h-16 max-h-16 h-16 shrink-0 flex sticky top-0 z-20 border-b border-b-white bg-black overflow-x-hidden",children:Z.jsx(d2,{onMenuClick:()=>o(!0)})}),Z.jsx("div",{id:"currentpagecontainer",className:"w-full grow overflow-y-auto",children:Z.jsx(N1,{children:s?Z.jsxs(Z.Fragment,{children:[Z.jsx(_a,{path:"/",element:Z.jsx(K0,{to:"/results",replace:!0})}),Z.jsx(_a,{path:"/results",element:Z.jsx(g2,{})}),Z.jsx(_a,{path:"/settings",element:Z.jsx(k0,{})})]}):Z.jsxs(Z.Fragment,{children:[Z.jsx(_a,{path:"/settings",element:Z.jsx(k0,{onConfigSaved:()=>r(!0)})}),Z.jsx(_a,{path:"*",element:Z.jsx(K0,{to:"/settings",replace:!0})})]})})}),Z.jsx("div",{className:`fixedtop-0left-0w-fullh-fullz-50bg-blacktransformtransition-transformduration-300ease-in-out${c?"translate-x-0":"-translate-x-full"}`,children:Z.jsx(y2,{onClose:()=>o(!1)})})]})})}Gm.createRoot(document.getElementById("root")).render(Z.jsx(_.StrictMode,{children:Z.jsx(p2,{})}));