HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/AppData/Local/Microsoft/OneDrive/26.168.0830.0006/WebAssets/static/view-lib/sql.js
window.ViewLib=window.ViewLib||{},function(){var E=0,m=0;function C(){try{for(var e=new Error().stack||"",n=e.split(`
`),r=3;r<n.length;r++){var t=n[r];if(t.indexOf("sql.js")===-1&&t.indexOf("_exec")===-1){var a=t.match(/at\s+(\S+)/);return a?a[1]:t.trim().substring(0,60)}}}catch{}return"?"}function D(e){if(!e)return!1;if(typeof e.sqliteCode=="number"){var n=e.sqliteCode&255;if(n===5||n===6)return!0}return!!(e.error&&(e.error.indexOf("ResultCode: 5")!==-1||e.error.indexOf("ResultCode: 6")!==-1||e.error.indexOf("is locked")!==-1))}function d(e,n,r,t,a){var u=r||0,i;a?i=a:(i={id:++E,t0:performance.now(),caller:C(),qn:t||"viewlib",sqlPreview:e.trim().replace(/\s+/g," ").substring(0,100)},m++,console.log("[sql] #"+i.id+" START ("+m+" inflight, caller: "+i.caller+") "+i.sqlPreview));var l=performance.now(),c=Date.now();return window.__vp_boot_phase&&window.__vp_boot_phase("FirstSqlRequest"),fetch("/api/od4sql?queryName="+encodeURIComponent(i.qn),{method:"POST",headers:{"Content-Type":ViewLib.ECS.jsonRequestContentType()},body:JSON.stringify({sql:e,params:n||[]}),_od4ApiName:"sql"}).then(function(o){window.__vp_boot_phase&&window.__vp_boot_phase("FirstSqlResponse");var _=Date.now();window.__vp_boot_span&&window.__vp_boot_span("Sql.Wait."+i.qn,c);var s=o.headers.get("X-Query-Duration-Ms")||"",w=o.headers.get("X-Queue-Wait-Ms")||"";return o.json().then(function(f){return window.__vp_boot_span&&window.__vp_boot_span("Sql.Parse."+i.qn,_,f&&f.rows?f.rows.length:0),f._queryDurationMs=s,f._queueWaitMs=w,f})}).then(function(o){var _=(performance.now()-l).toFixed(0),s=(performance.now()-i.t0).toFixed(0);if(o.error){if(D(o)&&u<6){var w=200*(u+1);return console.warn("[sql] #"+i.id+" LOCK retry "+(u+1)+"/6 in "+w+"ms (attempt took "+_+"ms)"),new Promise(function(Q){setTimeout(Q,w)}).then(function(){return d(e,n,u+1,t,i)})}if(u>0){var f=typeof o.sqliteCode=="number"?" (sqliteCode="+o.sqliteCode+")":"";console.error("[sql] #"+i.id+" GAVE UP after "+(u+1)+" attempts"+f+" in "+s+"ms: "+o.error)}else console.error("[sql] #"+i.id+" ERROR ("+s+"ms, caller: "+i.caller+"):",o.error,`
SQL:`,e.trim().substring(0,200));throw new Error("SQL error: "+o.error)}var M=o._queueWaitMs||o._queryDurationMs?" (queue: "+(o._queueWaitMs||"?")+"ms, sql: "+(o._queryDurationMs||"?")+"ms)":"";delete o._queryDurationMs,delete o._queueWaitMs;var I=s>500?console.warn:console.log;return I("[sql] #"+i.id+" "+s+"ms"+M+", "+o.rowCount+" rows"+(s>500?" SLOW":"")+(u>0?" (after "+(u+1)+" attempts)":"")+" (caller: "+i.caller+") "+i.sqlPreview+(n&&n.length?" [params: "+n.join(", ").substring(0,60)+"]":"")),o}).catch(function(o){if(u===0&&!(o.message&&o.message.indexOf("SQL error:")===0)){var _=(performance.now()-i.t0).toFixed(0);console.error("[sql] #"+i.id+" FAIL ("+_+"ms, caller: "+i.caller+"):",o.message)}throw o}).finally(function(){a||m--})}var h=null,v=null;function O(){return v||(v=new Promise(function(e,n){if(window.QueryPack){e();return}var r=document.createElement("script");r.src="/static/vendor/@onedrive/querypack.js",r.onload=e,r.onerror=function(){n(new Error("Failed to load querypack.js"))},document.head.appendChild(r)}).then(function(){h=window.QueryPack.Catalog.fromUrl("/sql/")}).catch(function(e){throw h=null,v=null,e}),v)}function S(e){return e.isNull()?null:e.type==="INT"?e.asInt():e.type==="REAL"?e.asReal():e.asText()}var A={media:1,listSync:1};function x(e){var n=[];if(e&&e.dbs)for(var r=0;r<e.dbs.length;r++)A[e.dbs[r].name]&&n.push(e.dbs[r].name);var t=!1;if(e&&e.withs){for(var a=0;a<e.withs.length;a++)if(e.withs[a].name==="account_scope"){t=!0;break}}return{accountDbs:n,hasAccountScopeWith:t}}function T(e,n){var r=new Error("SQL error: Query requires signed-in account");return r.errorCode="NoAccountContext",r.queryName=e,r.missingAccountDbs=n.slice(),r}function L(e,n,r){var t=x(n),a=typeof window<"u"&&window.__od4AccountCid||"";if(!a&&t.accountDbs.length>0&&!t.hasAccountScopeWith)throw console.warn("[sql:named] "+e+" NoAccountContext (missingAccountDbs="+t.accountDbs.join(",")+")"),T(e,t.accountDbs);if(!a||!t.hasAccountScopeWith)return r;var u=r&&r.with||{};if(u.account_scope)return r;var i={};Object.keys(u).forEach(function(c){i[c]=u[c]}),i.account_scope={account_id:a};var l={};return Object.keys(r||{}).forEach(function(c){l[c]=r[c]}),l.with=i,l}var k=6880,p="takenDateTimeNormalized",P="takenDateTime",y={dim_index_hint:"dim_index_hint_normalized",exclude_clutter_index_hint:"exclude_clutter_index_hint_normalized"};function j(){if(typeof window>"u"||!window.ViewLib||!window.ViewLib.ECS||typeof window.ViewLib.ECS.isKillswitchSafe!="function")return!0;try{return window.ViewLib.ECS.isKillswitchSafe(k)!==!1}catch{return!0}}function N(e,n){if(!e||n!==p)return null;var r=null;return Object.keys(y).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&(r||(r={},Object.keys(e).forEach(function(a){r[a]=e[a]})),r[y[t]]=r[t],delete r[t])}),r}function R(e,n,r){var t=n&&n.queryParams||[],a=t.some(function(s){return s.name==="taken_date_col"&&s.type==="IDEN"});if(!a)return r;var u=r&&r.params||{},i=u.taken_date_col!==void 0,l=i?u.taken_date_col:j()?p:P,c={};if(Object.keys(r||{}).forEach(function(s){c[s]=r[s]}),!i){var o={};Object.keys(u).forEach(function(s){o[s]=u[s]}),o.taken_date_col=l,c.params=o}var _=N(c.with,l);return _&&(c.with=_),c}function b(e,n){return O().then(function(){return h.resolveQuery(e)}).then(function(r){var t=L(e,r,n||{});t=R(e,r,t),W(e,t);var a=window.QueryPack.Value,u=t.params||{},i={};Object.keys(u).forEach(function(o){i[o]=q(u[o],o,r.queryParams,a)});var l=h.compose(e,i);if(t.with){var c=t.with;Object.keys(c).forEach(function(o){var _=c[o]||{},s=r.withs.find(function(f){return f.name===o}),w={};Object.keys(_).forEach(function(f){w[f]=q(_[f],f,s?s.params:[],a)}),l.with(o,w)})}return t.sort&&l.sort(t.sort),l.run()}).then(function(r){var t=r.params.map(S);return d(r.sql,t,0,e)})}function W(e,n){var r=n&&n.with||{},t=!!r.gallery_cloud,a=!!r.favorites,u=!!r.favorites_dep;if(e==="gallery_sorted_ids"){if(t&&!a&&!u)return;throw new Error("gallery_sorted_ids requires the gallery_cloud cloud mode and rejects favorites/favorites_dep (use favorites_sorted_ids).")}if(e==="favorites_sorted_ids"){var i=(a?1:0)+(u?1:0)==1;if(i&&!t)return;throw new Error("favorites_sorted_ids requires exactly one of favorites or favorites_dep and rejects gallery_cloud.")}}function q(e,n,r,t){if(typeof e!="string"||!r)return e;for(var a=0;a<r.length;a++)if(r[a].name===n)return r[a].type==="IDEN"?t.identifier(e):e;return e}function g(e){return e.rows.map(function(n){for(var r={},t=0;t<e.columns.length;t++)r[e.columns[t]]=n[t];return r})}window.ViewLib.SQL={query:function(e,n){return d(e,n).then(g)},queryRaw:function(e,n){return d(e,n)},scalar:function(e,n){return d(e,n).then(function(r){return r.rows.length===0?null:r.rows[0][0]})},named:function(e,n){return b(e,n||{}).then(g)},namedRaw:function(e,n){return b(e,n||{})}}}();