{"version":3,"file":"DescopeUserProfile.Dyu6NuFa.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/zltpTZztOazBHbWJeUyK/ZNdwoIfwjvb5CVQCsPP8/DescopeUserProfile.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// === Defaults based on your screenshots / project =========================\nconst DEFAULT_PROJECT_ID=\"P36J942hkZzXiM54p30sHKcDNmW9\";const DEFAULT_WIDGET_ID=\"user-profile-widget\";const DEFAULT_THEME=\"light\"// \"light\" | \"dark\" | \"os\"\n;const DEFAULT_STYLE_ID=\"\";// Pin to a concrete version (you can change it to the latest if you wish)\nconst WIDGET_SCRIPT_SRC=\"https://static.descope.com/npm/@descope/user-profile-widget@0.6.22/dist/index.js\";export function DescopeUserProfile(props){const{projectId=DEFAULT_PROJECT_ID,widgetId=DEFAULT_WIDGET_ID,theme=DEFAULT_THEME,styleId=DEFAULT_STYLE_ID,logoutRedirectUrl=\"/login\"}=props;const containerRef=useRef(null);useEffect(()=>{const loadScript=src=>new Promise((resolve,reject)=>{// Avoid loading the same script multiple times\n    const existing=document.querySelector(`script[src=\"${src}\"]`);if(existing){if(existing.dataset.loaded===\"true\"){resolve();}else{existing.addEventListener(\"load\",()=>resolve());existing.addEventListener(\"error\",()=>reject());}return;}const script=document.createElement(\"script\");script.src=src;script.async=true;script.onload=()=>{script.dataset.loaded=\"true\";resolve();};script.onerror=()=>reject();document.head.appendChild(script);});const init=async()=>{try{// 1) Load the Descope User Profile widget script\nawait loadScript(WIDGET_SCRIPT_SRC);const container=containerRef.current;if(!container)return;// 2) Inject the web component from Descope's \"Web Component\" code export\nif(!container.querySelector(\"descope-user-profile-widget\")){container.innerHTML=`\n                        <descope-user-profile-widget\n                            project-id=\"${projectId}\"\n                            widget-id=\"${widgetId}\"\n                            theme=\"${theme}\"\n                            style-id=\"${styleId}\"\n                        ></descope-user-profile-widget>\n                    `.trim();}// 3) Attach logout callback like in Descope example\nconst widgetEl=container.querySelector(\"descope-user-profile-widget\");if(widgetEl){widgetEl.logout=error=>{// You can inspect error if needed\nif(logoutRedirectUrl){window.location.href=logoutRedirectUrl;}else{window.location.reload();}};}}catch(err){console.error(\"[DescopeUserProfile] Failed to load user profile widget\",err);}};init();},[projectId,widgetId,theme,styleId,logoutRedirectUrl]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\"}});}// Make props editable from the Framer UI\naddPropertyControls(DescopeUserProfile,{projectId:{type:ControlType.String,title:\"Project ID\",defaultValue:DEFAULT_PROJECT_ID},widgetId:{type:ControlType.String,title:\"Widget ID\",defaultValue:DEFAULT_WIDGET_ID},theme:{type:ControlType.SegmentedEnum,title:\"Theme\",options:[\"light\",\"dark\",\"os\"],optionTitles:[\"Light\",\"Dark\",\"OS\"],defaultValue:DEFAULT_THEME},styleId:{type:ControlType.String,title:\"Style ID\",defaultValue:DEFAULT_STYLE_ID},logoutRedirectUrl:{type:ControlType.String,title:\"Logout redirect\",defaultValue:\"/login\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"DescopeUserProfile\":{\"type\":\"reactComponent\",\"name\":\"DescopeUserProfile\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DescopeUserProfile.map"],"mappings":"0LAG2G,SAAgB,EAAmB,EAAM,CAAC,GAAK,CAAC,YAAU,EAAmB,WAAS,EAAkB,QAAM,EAAc,UAAQ,EAAiB,oBAAkB,UAAU,EAAY,EAAaA,EAAO,KAAK,CAYtE,OAZuE,MAAc,CAAC,IAAM,EAAW,GAAK,IAAI,SAAS,EAAQ,IAAS,CACjY,IAAM,EAAS,SAAS,cAAc,eAAe,EAAI,IAAI,CAAC,GAAG,EAAS,CAAI,EAAS,QAAQ,SAAS,OAAQ,GAAS,EAAO,EAAS,iBAAiB,WAAW,GAAS,CAAC,CAAC,EAAS,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