Changed around line 1
+ /**
+ * @license
+ * Copyright 2023 Google LLC. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================================
+ */
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).tf=e.tf||{})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=function(e){return e&&e.Math==Math&&e},a=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(e){return!0}},o=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={}.propertyIsEnumerable,u=Object.getOwnPropertyDescriptor,l=u&&!s.call({1:2},1)?function(e){var t=u(this,e);return!!t&&t.enumerable}:s,c={f:l},p=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},h={}.toString,f=function(e){return h.call(e).slice(8,-1)},d="".split,m=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==f(e)?d.call(e,""):Object(e)}:Object,v=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},g=function(e){return m(v(e))},y=function(e){return"object"==typeof e?null!==e:"function"==typeof e},b=function(e,t){if(!y(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!y(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!y(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!y(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},x={}.hasOwnProperty,w=function(e,t){return x.call(e,t)},k=a.document,N=y(k)&&y(k.createElement),I=function(e){return N?k.createElement(e):{}},S=!o&&!i((function(){return 7!=Object.defineProperty(I("div"),"a",{get:function(){return 7}}).a})),T=Object.getOwnPropertyDescriptor,C={f:o?T:function(e,t){if(e=g(e),t=b(t,!0),S)try{return T(e,t)}catch(e){}if(w(e,t))return p(!c.f.call(e,t),e[t])}},E=function(e){if(!y(e))throw TypeError(String(e)+" is not an object");return e},A=Object.defineProperty,R={f:o?A:function(e,t,n){if(E(e),t=b(t,!0),E(n),S)try{return A(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},_=o?function(e,t,n){return R.f(e,t,p(1,n))}:function(e,t,n){return e[t]=n,e},O=function(e,t){try{_(a,e,t)}catch(n){a[e]=t}return t},F="__core-js_shared__",D=a[F]||O(F,{}),M=Function.toString;"function"!=typeof D.inspectSource&&(D.inspectSource=function(e){return M.call(e)});var L,z,P,B=D.inspectSource,W=a.WeakMap,V="function"==typeof W&&/native code/.test(B(W)),U=n((function(e){(e.exports=function(e,t){return D[e]||(D[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.9.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),G=0,j=Math.random(),H=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++G+j).toString(36)},q=U("keys"),K=function(e){return q[e]||(q[e]=H(e))},X={},Y=a.WeakMap;if(V){var J=D.state||(D.state=new Y),Z=J.get,Q=J.has,$=J.set;L=function(e,t){return t.facade=e,$.call(J,e,t),t},z=function(e){return Z.call(J,e)||{}},P=function(e){return Q.call(J,e)}}else{var ee=K("state");X[ee]=!0,L=function(e,t){return t.facade=e,_(e,ee,t),t},z=function(e){return w(e,ee)?e[ee]:{}},P=function(e){return w(e,ee)}}var te,ne,re={set:L,get:z,has:P,enforce:function(e){return P(e)?z(e):L(e,{})},getterFor:function(e){return function(t){var n;if(!y(t)||(n=z(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},ae=n((function(e){var t=re.get,n=re.enforce,r=String(String).split("String");(e.exports=function(e,t,i,o){var s,u=!!o&&!!o.unsafe,l=!!o&&!!o.enumerable,c=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof t||w(i,"name")||_(i,"name",t),(s=n(i)).source||(s.source=r.join("string"==typeof t?t:""))),e!==a?(u?!c&&e[t]&&(l=!0):delete e[t],l?e[t]=i:_(e,t,i)):l?e[t]=i:O(t,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||B(this)}))})),ie=a,oe=function(e){return"function"==typeof e?e:void 0},se=function(e,t){return arguments.length<2?oe(ie[e])||oe(a[e]):ie[e]&&ie[e][t]||a[e]&&a[e][t]},ue=Math.ceil,le=Math.floor,ce=function(e){return isNaN(e=+e)?0:(e>0?le:ue)(e)},pe=Math.min,he=function(e){return e>0?pe(ce(e),9007199254740991):0},fe=Math.max,de=Math.min,me=function(e,t){var n=ce(e);return n<0?fe(n+t,0):de(n,t)},ve=function(e){return function(t,n,r){var a,i=g(t),o=he(i.length),s=me(r,o);if(e&&n!=n){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},ge={includes:ve(!0),indexOf:ve(!1)},ye=ge.indexOf,be=function(e,t){var n,r=g(e),a=0,i=[];for(n in r)!w(X,n)&&w(r,n)&&i.push(n);for(;t.length>a;)w(r,n=t[a++])&&(~ye(i,n)||i.push(n));return i},xe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],we=xe.concat("length","prototype"),ke={f:Object.getOwnPropertyNames||function(e){return be(e,we)}},Ne={f:Object.getOwnPropertySymbols},Ie=se("Reflect","ownKeys")||function(e){var t=ke.f(E(e)),n=Ne.f;return n?t.concat(n(e)):t},Se=function(e,t){for(var n=Ie(t),r=R.f,a=C.f,i=0;i=74)&&(te=Le.match(/Chrome\/(\d+)/))&&(ne=te[1]);var We,Ve=ne&&+ne,Ue=!!Object.getOwnPropertySymbols&&!i((function(){return!Symbol.sham&&(Me?38===Ve:Ve>37&&Ve<41)})),Ge=Ue&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,je=Array.isArray||function(e){return"Array"==f(e)},He=function(e){return Object(v(e))},qe=Object.keys||function(e){return be(e,xe)},Ke=o?Object.defineProperties:function(e,t){E(e);for(var n,r=qe(t),a=r.length,i=0;a>i;)R.f(e,n=r[i++],t[n]);return e},Xe=se("document","documentElement"),Ye=K("IE_PROTO"),Je=function(){},Ze=function(e){return"
+
+
+ body {
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
+ sans-serif;
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 20px;
+ background: #f5f5f5;
+ }
+ .container {
+ background: white;
+ padding: 20px;
+ border-radius: 8px;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+ }
+ textarea {
+ width: 100%;
+ height: 200px;
+ margin: 10px 0;
+ padding: 10px;
+ border: 1px solid #ddd;
+ border-radius: 4px;
+ font-size: 16px;
+ }
+ .visualization {
+ display: inline-block;
+ position: relative;
+ margin: 20px 0;
+ border: 1px solid #ddd;
+ border-radius: 4px;
+ background: white;
+ width: calc(100% - 330px);
+ }
+ .results {
+ display: inline-block;
+ width: 300px;
+ min-height: 150px;
+ vertical-align: top;
+ }
+ button {
+ background: #0066cc;
+ color: white;
+ border: none;
+ padding: 10px 20px;
+ border-radius: 4px;
+ cursor: pointer;
+ font-size: 16px;
+ margin: 5px;
+ }
+ button:hover {
+ background: #0052a3;
+ }
+ .pro-button {
+ background: #gold;
+ }
+ .resultsHolder {
+ margin-top: 20px;
+ padding: 20px;
+ background: #f8f9fa;
+ border-radius: 4px;
+ }
+ #focusThought {
+ padding: 8px;
+ font-size: 16px;
+ margin: 10px 0;
+ width: 400px;
+ }
+ .input-container {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ }
+ .sample-link {
+ color: #0066cc;
+ text-decoration: underline;
+ cursor: pointer;
+ }
+ .sample-link:hover {
+ color: #0052a3;
+ }
+
+
+
+
+
ThoughtFocus · Measure Your Focus by Your Words · TF = FT/T
+
+
+
+ type="text"
+ id="focusThought"
+ placeholder="What is your current focus? Try to describe in 1 word."
+ />
+
+ Paste everything you wrote today, each message or document on its own
+ line. Emails, tweets, texts, etc, to calculate your ThoughtFocus.
+
+
+
+
+
+
+ Calculate ThoughtFocus (Basic)
+
+
+ Calculate ThoughtFocus (Pro)
+
+
+
+
+
+
+ let embeddings = [];
+ let projectedPoints = [];
+ let chart = null;
+
+ function loadSampleData() {
+ const sampleMessages = [
+ "Coach wants us to review the new football plays before practice today",
+ "Got my history essay deadline extended. Thank goodness, have football practice all week",
+ "Anyone want to grab lunch at the dining hall? Practice ran late",
+ "Need to ice my shoulder after that tackle drill at football practice",
+ "Study group for Bio at 7pm - can't miss this one even with game prep",
+ "Watch film from last week's football game. Defense looking solid!",
+ "Math homework done ✓ Now time to hit the weight room",
+ "Team meeting at 3pm to discuss Saturday's football game plan",
+ "Pizza with the guys after football practice. Best recovery meal!",
+ "Need to finish this psychology reading before tomorrow's football practice",
+ "Football game this Saturday! Can't wait to show what we've been working on",
+ "Morning conditioning was brutal but getting stronger for football season",
+ "Anyone recorded the lecture? Had to meet with football coach during class",
+ "Library study session before evening football practice",
+ "New football cleats just arrived! Breaking them in tomorrow",
+ "Group project meeting at 2pm, then straight to football field",
+ "Watching NFL games for homework - analyzing defensive strategies",
+ "Late night study grind. These football plays won't memorize themselves",
+ "Morning workout done. Ready for both classes and football today",
+ "Team bonding night! Football season is gonna be epic",
+ ].join("\n\n");
+
+ document.getElementById("focusThought").value = "football";
+ document.getElementById("textInput").value = sampleMessages;
+
+ // Automatically trigger analysis
+ analyzeText();
+ calculateFocusArea();
+ }
+
+ // Rest of the JavaScript remains the same
+ function basicEmbedding(text) {
+ const words = text
+ .toLowerCase()
+ .split(/\W+/)
+ .filter((w) => w.length > 0);
+ return words.map((word) => {
+ const x = word.length / 10;
+ const y =
+ Array.from(word).reduce(
+ (sum, char) => sum + char.charCodeAt(0),
+ 0,
+ ) / 1000;
+ return [x, y];
+ });
+ }
+
+ function simplePCA(data) {
+ const mean = data
+ .reduce(
+ (acc, point) => [acc[0] + point[0], acc[1] + point[1]],
+ [0, 0],
+ )
+ .map((sum) => sum / data.length);
+
+ const centered = data.map((point) => [
+ point[0] - mean[0],
+ point[1] - mean[1],
+ ]);
+
+ const covar = [
+ [0, 0],
+ [0, 0],
+ ];
+
+ for (const point of centered) {
+ covar[0][0] += point[0] * point[0];
+ covar[0][1] += point[0] * point[1];
+ covar[1][0] += point[0] * point[1];
+ covar[1][1] += point[1] * point[1];
+ }
+
+ return centered.map((point) => [
+ point[0] * covar[0][0] + point[1] * covar[0][1],
+ point[0] * covar[1][0] + point[1] * covar[1][1],
+ ]);
+ }
+
+ function analyzeText() {
+ const text = document.getElementById("textInput").value;
+ embeddings = basicEmbedding(text);
+ projectedPoints = simplePCA(embeddings);
+ updateVisualization();
+ }
+
+ function analyzeTextPro() {
+ window.location = "https://buy.stripe.com/9AQ3fYgzfgHbguY5kP";
+ }
+
+ function updateVisualization() {
+ const ctx = document.getElementById("plotCanvas").getContext("2d");
+
+ if (chart) {
+ chart.destroy();
+ }
+
+ chart = new Chart(ctx, {
+ type: "scatter",
+ data: {
+ datasets: [
+ {
+ label: "Thought Embeddings",
+ data: projectedPoints.map((point) => ({
+ x: point[0],
+ y: point[1],
+ })),
+ backgroundColor: "rgba(0, 102, 204, 0.5)",
+ },
+ ],
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ scales: {
+ x: {
+ type: "linear",
+ position: "bottom",
+ },
+ },
+ },
+ });
+ }
+
+ function calculateFocusArea() {
+ const focusThought = document
+ .getElementById("focusThought")
+ .value.toLowerCase();
+ const text = document.getElementById("textInput").value;
+ const lines = text
+ .toLowerCase()
+ .split(/\n+/)
+ .filter((w) => w.length > 0);
+
+ const totalLines = lines.length;
+ const hits = lines.filter((line) => line.includes(focusThought)).length;
+ const focusScore = (100 * hits) / totalLines;
+
+ document.getElementById("results").innerHTML = `
+
ThoughtFocus Results
+
Total Thoughts: ${totalLines}
+
ThoughtFocus for ${focusThought}: ${focusScore.toFixed(0)}% 🔍
+ `;
+ }
+
+
+