/*! Sentrize v3.0.0 · content/settings.js · sentrize.com
 * Minified with terser/csso: local variable renaming and
 * whitespace/comment removal ONLY. No obfuscation, no control-flow flattening, no string encoding. */
self.MVC=self.MVC||{},function(){const e="sentrizeMode",t="sentrizeWorkspaceSettings",n="sentrizeWorkspaceFavorites",r=["white","dark","sky","slate","purple-light","purple-dark"],o=[.5,.6,.7,.8,.9,1,1.25,1.5,1.75,2],s=o[0],l=o[o.length-1],c=["left","center"],i=[.8,.9,1,1.1,1.25,1.4,1.6,1.8,2];let a=1;function u(e){const t=Number(e);if(!isFinite(t))return 1;let n=o[0],r=Math.abs(t-n);for(let e=1;e<o.length;e++){const s=Math.abs(t-o[e]);s<r&&(n=o[e],r=s)}return n}function f(e){const t=Number(e);if(!isFinite(t))return 1;let n=i[0],r=Math.abs(t-n);for(let e=1;e<i.length;e++){const o=Math.abs(t-i[e]);o<r&&(n=i[e],r=o)}return n}function S(){return"slot-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,8)}function g(e){const t={version:1,background:"purple-dark",align:"left",uiScale:1,slots:[{id:"slot-1",presetKey:"iphone16pro",rotated:!1,scale:1},{id:"slot-2",presetKey:"pixel6pro",rotated:!1,scale:1},{id:"slot-3",presetKey:"ipadmini",rotated:!1,scale:1}]};if(!e||"object"!=typeof e)return t;if(r.indexOf(e.background)>=0&&(t.background=e.background),c.indexOf(e.align)>=0&&(t.align=e.align),null!=e.uiScale&&(t.uiScale=f(e.uiScale)),!Array.isArray(e.slots))return t;const n=self.MV&&self.MV.WORKSPACE_DEVICES||[],o={};for(let e=0;e<n.length;e++)o[n[e].key]=!0;const s=[];for(let t=0;t<e.slots.length&&s.length<10;t++){const n=e.slots[t];n&&n.presetKey&&o[n.presetKey]&&s.push({id:"string"==typeof n.id&&n.id?n.id:S(),presetKey:n.presetKey,rotated:!!n.rotated,scale:u(null!=n.scale?n.scale:1)})}return t.slots=s,t}function p(e){const t=self.MV&&self.MV.WORKSPACE_DEVICES||[],n={};for(let e=0;e<t.length;e++)n[t[e].key]=!0;const r=[];if(!Array.isArray(e))return r;for(let t=0;t<e.length&&r.length<5;t++){const o=e[t];"string"==typeof o&&n[o]&&r.indexOf(o)<0&&r.push(o)}return r}function h(e){try{chrome.storage.local.get(n,t=>{e(p(t&&t[n]))})}catch(t){e([])}}Object.assign(self.MVC,{MODE_KEY:e,CLASSIC_KEY:"sentrizeSettings",WORKSPACE_KEY:t,WORKSPACE_MAX_SLOTS:10,WORKSPACE_FAV_MAX:5,WORKSPACE_SCALE_MIN:s,WORKSPACE_SCALE_MAX:l,WORKSPACE_DEFAULT_SCALE:1,WORKSPACE_BASE_CSS_TO_SCREEN:.5,WORKSPACE_UI_STEPS:i,WORKSPACE_UI_DEFAULT:1,clampScale:u,largestScaleStepAtMost:function(e){const t=null!=e&&isFinite(Number(e))?Number(e):l;let n=s;for(let e=0;e<o.length;e++)o[e]<=t+1e-9&&(n=o[e]);return n},formatScale:function(e){return String(u(e))+"×"},stepWorkspaceScale:function(e,t,n){const r=u(e);let s=o.indexOf(r);if(s<0&&(s=0),t<0)return s>0?o[s-1]:r;const c=null==n?l:Number(n);for(let e=s+1;e<o.length;e++)if(o[e]<=c+1e-9)return o[e];return r},clampUiScale:f,stepUiScale:function(e,t){const n=f(e),r=i.indexOf(n);return r<0?n:t<0?r>0?i[r-1]:n:r<i.length-1?i[r+1]:n},formatUiScale:function(e){return Math.round(100*f(e))+"%"},uiScale:function(){return a},setUiScaleRuntime:function(e){return a=f(e),a},newSlotId:S,normalizeWorkspace:g,getMode:function(t){try{chrome.storage.local.get(e,n=>{t(n&&"workspace"===n[e]?"workspace":"classic")})}catch(e){t("classic")}},setMode:function(t,n){const r="workspace"===t?"workspace":"classic";try{chrome.storage.local.set({[e]:r},()=>{n&&n(r)})}catch(e){n&&n(r)}},setWorkspace:function(e,n){const r=g(e);try{chrome.storage.local.set({[t]:r},()=>{n&&n(r)})}catch(e){n&&n(r)}},normalizeFavorites:p,getWorkspaceFavorites:h,toggleWorkspaceFavorite:function(e,t){h(r=>{const o=r.indexOf(e);if(o>=0)r.splice(o,1);else{if(r.length>=5)return void(t&&t(r,{limited:!0}));r.push(e)}!function(e,t){const r=p(e);try{chrome.storage.local.set({[n]:r},()=>{t&&t(r)})}catch(e){t&&t(r)}}(r,e=>{t&&t(e,{})})})}})}();
